From 5871f31c2f7255dbe7512d18d82134eb4bb8acf6 Mon Sep 17 00:00:00 2001 From: Eric Burgess Date: Tue, 19 Jun 2018 13:15:32 -0500 Subject: [PATCH] initialize controllerstate once so control settings persist from tick to tick. --- python_example/python_example.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/python_example/python_example.py b/python_example/python_example.py index 9ab6d15..1c49ea6 100644 --- a/python_example/python_example.py +++ b/python_example/python_example.py @@ -8,11 +8,9 @@ class PythonExample(BaseAgent): def initialize_agent(self): #This runs once before the bot starts up - pass + self.controller_state = SimpleControllerState() def get_output(self, packet: GameTickPacket) -> SimpleControllerState: - controller_state = SimpleControllerState() - ball_location = Vector2(packet.game_ball.physics.location.x, packet.game_ball.physics.location.y) my_car = packet.game_cars[self.index] @@ -28,10 +26,10 @@ def get_output(self, packet: GameTickPacket) -> SimpleControllerState: else: turn = 1.0 - controller_state.throttle = 1.0 - controller_state.steer = turn + self.controller_state.throttle = 1.0 + self.controller_state.steer = turn - return controller_state + return self.controller_state class Vector2: