fix: plot axis

This commit is contained in:
2025-04-15 13:01:52 +03:00
parent b8429d263f
commit 3c568ac93a

View File

@@ -5,6 +5,8 @@ from time import sleep
# from scipy import
from matplotlib import pyplot as plt
random.seed(1)
class RandomPilot():
angle: float
@@ -27,18 +29,27 @@ class RandomPilot():
def _test():
randomPilot = RandomPilot()
point = [0, 0]
iter_count = 250
iter_count = 100
points = [point.copy()]
plt.axis([-100, 100, -100, 100])
# plt.
for i in range(iter_count):
dx, dy = randomPilot.step()
prev_point = point.copy()
point[0] += dx
point[1] += dy
points.append(point.copy())
plt.plot(*zip(*points[-2:]), color='#5e5')
plt.pause(0.025)
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__':