Skip to content

Commit c3ca330

Browse files
committed
Switching from jitpack to jcenter and converting to a flatbuffer bot.
1 parent 91bf87d commit c3ca330

2 files changed

Lines changed: 22 additions & 23 deletions

File tree

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
apply plugin: 'java'
66

77
repositories {
8-
maven { url 'https://jitpack.io' }
8+
jcenter()
99
}
1010

1111
dependencies {
1212
// Fetch the framework zip file. This will automatically stay up-to-date with the latest changes in the v4 branch.
1313
// This is useful for automatically getting fixes when the framework breaks due to Rocket League patches.
1414
// For different behavior, e.g. freezing at a specific version of the framework, see https://jitpack.io/docs/
15-
compile 'com.github.RLBot:RLBot:v4-SNAPSHOT:python@zip'
15+
compile 'org.rlbot.commons:framework:0.0.1:python@zip'
1616
}
1717

1818
// Handy helper method for finding the actual files involved with a compile dependency.

python_example/python_example.py

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

3-
from RLBotFramework.agents.base_agent import BaseAgent
3+
from RLBotFramework.agents.base_flatbuffer_agent import BaseFlatbufferAgent, SimpleControllerState
4+
from RLBotMessages.flat import GameTickPacket
45

56
URotationToRadians = math.pi / float(32768)
67

78

8-
class PythonExample(BaseAgent):
9+
class PythonExample(BaseFlatbufferAgent):
910

10-
def get_output_vector(self, game_tick_packet):
11+
def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
12+
controller_state = SimpleControllerState()
1113

12-
ball_location = Vector2(game_tick_packet.gameball.Location.X, game_tick_packet.gameball.Location.Y)
14+
if packet.Ball() is None: # This happens during replays
15+
return controller_state
1316

14-
my_car = game_tick_packet.gamecars[self.index]
15-
car_location = Vector2(my_car.Location.X, my_car.Location.Y)
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())
1621
car_direction = get_car_facing_vector(my_car)
1722
car_to_ball = ball_location - car_location
1823

1924
steer_correction_radians = car_direction.correction_to(car_to_ball)
2025

2126
if steer_correction_radians > 0:
2227
# Positive radians in the unit circle is a turn to the left.
23-
turn = -1.0 # Negative value for a turn to the left.
28+
turn = -1.0 # Negative value for a turn to the left.
2429
else:
2530
turn = 1.0
2631

27-
return [
28-
1.0, # throttle
29-
turn, # steer
30-
0.0, # pitch
31-
0.0, # yaw
32-
0.0, # roll
33-
0, # jump
34-
0, # boost
35-
0 # handbrake
36-
]
32+
controller_state.throttle = 1.0
33+
controller_state.steer = turn
34+
35+
return controller_state
3736

3837

3938
class Vector2:
@@ -65,10 +64,10 @@ def correction_to(self, ideal):
6564

6665

6766
def get_car_facing_vector(car):
68-
pitch = float(car.Rotation.Pitch)
69-
yaw = float(car.Rotation.Yaw)
67+
pitch = car.Physics().Rotation().Pitch()
68+
yaw = car.Physics().Rotation().Yaw()
7069

71-
facing_x = math.cos(pitch * URotationToRadians) * math.cos(yaw * URotationToRadians)
72-
facing_y = math.cos(pitch * URotationToRadians) * math.sin(yaw * URotationToRadians)
70+
facing_x = math.cos(pitch) * math.cos(yaw)
71+
facing_y = math.cos(pitch) * math.sin(yaw)
7372

7473
return Vector2(facing_x, facing_y)

0 commit comments

Comments
 (0)