diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0e5ac79 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.venv +__pycache__ \ No newline at end of file diff --git a/main.py b/main.py index d0fe6b1..2d6e202 100644 --- a/main.py +++ b/main.py @@ -7,6 +7,8 @@ import selenium from selenium.webdriver.common.by import By from selenium.webdriver.common.action_chains import ActionChains +from random_pilot import RandomPilot + options = webdriver.ChromeOptions() options.add_experimental_option("detach", True) driver = webdriver.Chrome(options) @@ -29,26 +31,8 @@ action.click(driver.find_element(By.CLASS_NAME, '_key_satellite')) action.pause(0.2) action.perform() -class RandomPilot(): - angle: float - def __init__(self): - self.dangle = 0 - self.angle = random.random() * math.pi * 2 - self.velocity = 50 - - def step(self) -> tuple[float, float]: - # Поворот угла траектории - self.dangle += (random.random() - 0.5) * 0.1 - self.dangle = max(min(self.dangle, 0.2), -0.2) - self.angle += self.dangle - - dx = math.cos(self.angle) * self.velocity - dy = math.sin(self.angle) * self.velocity - - return dx, dy - -randomPilot = RandomPilot() +randomPilot = RandomPilot(100) while True: # Сдвиг камеры diff --git a/random_pilot.py b/random_pilot.py new file mode 100644 index 0000000..96f48ce --- /dev/null +++ b/random_pilot.py @@ -0,0 +1,43 @@ +import math +import random + +# from scipy import +from matplotlib import pyplot as plt + +class RandomPilot(): + angle: float + + def __init__(self, velocity: float = 1): + self.dangle = 0 + self.angle = random.random() * math.pi * 2 + self.velocity = velocity + + def step(self) -> tuple[float, float]: + # Поворот угла траектории + self.dangle += (random.random() - 0.5) * 0.1 + self.dangle = max(min(self.dangle, 0.2), -0.2) + self.angle += self.dangle + + dx = math.cos(self.angle) * self.velocity + dy = math.sin(self.angle) * self.velocity + + return dx, dy + +def _test(): + randomPilot = RandomPilot() + point = [0, 0] + iter_count = 500 + points = [point.copy()] + for i in range(iter_count): + dx, dy = randomPilot.step() + point[0] += dx + point[1] += dy + points.append(point.copy()) + print(*zip(*points)) + plt.plot(*zip(*points), '--') + plt.show() + + + +if __name__ == '__main__': + _test() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e607ee6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,29 @@ +attrs==25.3.0 +certifi==2025.1.31 +cffi==1.17.1 +contourpy==1.3.1 +cycler==0.12.1 +fonttools==4.57.0 +h11==0.14.0 +idna==3.10 +kiwisolver==1.4.8 +matplotlib==3.10.1 +numpy==2.2.4 +outcome==1.3.0.post0 +packaging==24.2 +pillow==11.2.1 +pycparser==2.22 +pyparsing==3.2.3 +PySocks==1.7.1 +python-dateutil==2.9.0.post0 +scipy==1.15.2 +selenium==4.31.0 +six==1.17.0 +sniffio==1.3.1 +sortedcontainers==2.4.0 +trio==0.29.0 +trio-websocket==0.12.2 +typing_extensions==4.13.2 +urllib3==2.4.0 +websocket-client==1.8.0 +wsproto==1.2.0