From afcb6f599910a2ac614ec621002516f4ce7a2e1d Mon Sep 17 00:00:00 2001 From: dtracers Date: Sun, 3 Jun 2018 18:05:11 -0700 Subject: [PATCH 1/4] Updated to use simple controller state --- python_example/python_example.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/python_example/python_example.py b/python_example/python_example.py index a95411a..137a901 100644 --- a/python_example/python_example.py +++ b/python_example/python_example.py @@ -1,23 +1,21 @@ import math -from rlbot.agents.base_flatbuffer_agent import BaseFlatbufferAgent, SimpleControllerState -from rlbot.messages.flat import GameTickPacket +from rlbot.agents.base_agent import BaseAgent, SimpleControllerState +from rlbot.utils.structures.game_data_struct import GameTickPacket URotationToRadians = math.pi / float(32768) -class PythonExample(BaseFlatbufferAgent): +class PythonExample(BaseAgent): - def get_output(self, packet: GameTickPacket) -> SimpleControllerState: + def get_output_vector(self, packet: GameTickPacket) -> SimpleControllerState: controller_state = SimpleControllerState() - if packet.Ball() is None: # This happens during replays - return controller_state + ball_location = Vector2(packet.game_ball.physics.location.x, + packet.game_ball.physics.location.y) - ball_location = Vector2(packet.Ball().Physics().Location().X(), packet.Ball().Physics().Location().Y()) - - my_car = packet.Players(self.index) - car_location = Vector2(my_car.Physics().Location().X(), my_car.Physics().Location().Y()) + my_car = packet.game_cars[self.index] + car_location = Vector2(my_car.physics.location.x, my_car.physics.location.y) car_direction = get_car_facing_vector(my_car) car_to_ball = ball_location - car_location @@ -64,8 +62,8 @@ def correction_to(self, ideal): def get_car_facing_vector(car): - pitch = car.Physics().Rotation().Pitch() - yaw = car.Physics().Rotation().Yaw() + pitch = float(car.physics.rotation.pitch) + yaw = float(car.physics.rotation.yaw) facing_x = math.cos(pitch) * math.cos(yaw) facing_y = math.cos(pitch) * math.sin(yaw) From 6cdb017bba22cf1b98b7ab7f0ec7c2b9a09ddb0d Mon Sep 17 00:00:00 2001 From: dtracers Date: Sun, 3 Jun 2018 18:21:05 -0700 Subject: [PATCH 2/4] changed to get_output --- python_example/python_example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_example/python_example.py b/python_example/python_example.py index 137a901..cad692f 100644 --- a/python_example/python_example.py +++ b/python_example/python_example.py @@ -8,7 +8,7 @@ class PythonExample(BaseAgent): - def get_output_vector(self, packet: GameTickPacket) -> SimpleControllerState: + def get_output(self, packet: GameTickPacket) -> SimpleControllerState: controller_state = SimpleControllerState() ball_location = Vector2(packet.game_ball.physics.location.x, From bc332c7a74c5c21b311a2eb552ca38933cf59901 Mon Sep 17 00:00:00 2001 From: dtracers Date: Sun, 3 Jun 2018 18:26:25 -0700 Subject: [PATCH 3/4] made changes cleaner --- python_example/python_example.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_example/python_example.py b/python_example/python_example.py index cad692f..6c96574 100644 --- a/python_example/python_example.py +++ b/python_example/python_example.py @@ -1,7 +1,7 @@ import math -from rlbot.agents.base_agent import BaseAgent, SimpleControllerState from rlbot.utils.structures.game_data_struct import GameTickPacket +from rlbot.agents.base_agent import BaseAgent, SimpleControllerState URotationToRadians = math.pi / float(32768) From c80972451b2e47ff4952de7b46f2e1c244379818 Mon Sep 17 00:00:00 2001 From: dtracers Date: Sun, 3 Jun 2018 18:27:34 -0700 Subject: [PATCH 4/4] made changes even simpler --- python_example/python_example.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python_example/python_example.py b/python_example/python_example.py index 6c96574..0b76a26 100644 --- a/python_example/python_example.py +++ b/python_example/python_example.py @@ -1,7 +1,7 @@ import math -from rlbot.utils.structures.game_data_struct import GameTickPacket from rlbot.agents.base_agent import BaseAgent, SimpleControllerState +from rlbot.utils.structures.game_data_struct import GameTickPacket URotationToRadians = math.pi / float(32768) @@ -11,8 +11,7 @@ class PythonExample(BaseAgent): 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) + ball_location = Vector2(packet.game_ball.physics.location.x, packet.game_ball.physics.location.y) my_car = packet.game_cars[self.index] car_location = Vector2(my_car.physics.location.x, my_car.physics.location.y)