Skip to content

Commit 3faf021

Browse files
dtracerstarehart
authored andcommitted
Updated to extend BaseAgent instead of BaseFlatbufferAgent. (#1)
1 parent 2a75d39 commit 3faf021

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

python_example/python_example.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
import math
22

3-
from rlbot.agents.base_flatbuffer_agent import BaseFlatbufferAgent, SimpleControllerState
4-
from rlbot.messages.flat import GameTickPacket
3+
from rlbot.agents.base_agent import BaseAgent, SimpleControllerState
4+
from rlbot.utils.structures.game_data_struct import GameTickPacket
55

66
URotationToRadians = math.pi / float(32768)
77

88

9-
class PythonExample(BaseFlatbufferAgent):
9+
class PythonExample(BaseAgent):
1010

1111
def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
1212
controller_state = SimpleControllerState()
1313

14-
if packet.Ball() is None: # This happens during replays
15-
return controller_state
14+
ball_location = Vector2(packet.game_ball.physics.location.x, packet.game_ball.physics.location.y)
1615

17-
ball_location = Vector2(packet.Ball().Physics().Location().X(), packet.Ball().Physics().Location().Y())
18-
19-
my_car = packet.Players(self.index)
20-
car_location = Vector2(my_car.Physics().Location().X(), my_car.Physics().Location().Y())
16+
my_car = packet.game_cars[self.index]
17+
car_location = Vector2(my_car.physics.location.x, my_car.physics.location.y)
2118
car_direction = get_car_facing_vector(my_car)
2219
car_to_ball = ball_location - car_location
2320

@@ -64,8 +61,8 @@ def correction_to(self, ideal):
6461

6562

6663
def get_car_facing_vector(car):
67-
pitch = car.Physics().Rotation().Pitch()
68-
yaw = car.Physics().Rotation().Yaw()
64+
pitch = float(car.physics.rotation.pitch)
65+
yaw = float(car.physics.rotation.yaw)
6966

7067
facing_x = math.cos(pitch) * math.cos(yaw)
7168
facing_y = math.cos(pitch) * math.sin(yaw)

0 commit comments

Comments
 (0)