From b8429d263fc4edca7e2914c66d54888fb71455d4 Mon Sep 17 00:00:00 2001 From: russian_proger Date: Tue, 15 Apr 2025 12:49:25 +0300 Subject: [PATCH] feat: interactive trajectory --- random_pilot.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/random_pilot.py b/random_pilot.py index 96f48ce..4332b91 100644 --- a/random_pilot.py +++ b/random_pilot.py @@ -1,5 +1,6 @@ import math import random +from time import sleep # from scipy import from matplotlib import pyplot as plt @@ -26,18 +27,19 @@ class RandomPilot(): def _test(): randomPilot = RandomPilot() point = [0, 0] - iter_count = 500 + iter_count = 250 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()) - print(*zip(*points)) - plt.plot(*zip(*points), '--') - plt.show() - - + plt.plot(*zip(*points[-2:]), color='#5e5') + plt.pause(0.025) + sleep(1) if __name__ == '__main__': _test() \ No newline at end of file