Skip to content

Commit c3ec6e6

Browse files
ericmburgesstarehart
authored andcommitted
initialize controllerstate once so control settings persist from tick to tick. (#5)
1 parent 8e6e937 commit c3ec6e6

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

python_example/python_example.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ class PythonExample(BaseAgent):
88

99
def initialize_agent(self):
1010
#This runs once before the bot starts up
11-
pass
11+
self.controller_state = SimpleControllerState()
1212

1313
def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
14-
controller_state = SimpleControllerState()
15-
1614
ball_location = Vector2(packet.game_ball.physics.location.x, packet.game_ball.physics.location.y)
1715

1816
my_car = packet.game_cars[self.index]
@@ -28,10 +26,10 @@ def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
2826
else:
2927
turn = 1.0
3028

31-
controller_state.throttle = 1.0
32-
controller_state.steer = turn
29+
self.controller_state.throttle = 1.0
30+
self.controller_state.steer = turn
3331

34-
return controller_state
32+
return self.controller_state
3533

3634

3735
class Vector2:

0 commit comments

Comments
 (0)