ref: split program into classes
This commit is contained in:
50
autopilot.py
Normal file
50
autopilot.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import math
|
||||
import random
|
||||
from time import sleep
|
||||
|
||||
import numpy as np
|
||||
|
||||
# from scipy import
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
random.seed(1)
|
||||
|
||||
class Pilot:
|
||||
def __init__(self): pass
|
||||
def handle(self, image: np.ndarray): pass
|
||||
def act(self) -> float | None: pass
|
||||
|
||||
class RandomPilot(Pilot):
|
||||
def __init__(self, velocity: float = 1):
|
||||
pass
|
||||
|
||||
def act(self) -> float:
|
||||
return (random.random() - 0.5) * 0.1
|
||||
|
||||
# def _test():
|
||||
# randomPilot = RandomPilot()
|
||||
# point = [0, 0]
|
||||
# iter_count = 100
|
||||
# points = [point.copy()]
|
||||
|
||||
# for i in range(iter_count):
|
||||
# dx, dy = randomPilot.step()
|
||||
# prev_point = point.copy()
|
||||
# point[0] += dx
|
||||
# point[1] += dy
|
||||
# points.append(point.copy())
|
||||
|
||||
# coords = list(zip(*points))
|
||||
# padding = 5
|
||||
# plt.axis([
|
||||
# min(coords[0]) - padding, max(coords[0]) + padding,
|
||||
# min(coords[1]) - padding, max(coords[1]) + padding])
|
||||
|
||||
# for i in range(iter_count):
|
||||
# plt.plot(coords[0][i:i+2], coords[1][i:i+2], color='#5e5')
|
||||
# plt.pause(0.05)
|
||||
|
||||
# sleep(1)
|
||||
|
||||
# if __name__ == '__main__':
|
||||
# _test()
|
||||
Reference in New Issue
Block a user