1
1
from rlbot .flat import BallAnchor , ControllerState , GamePacket
2
2
from rlbot .managers import Bot
3
+ from rlbot_flatbuffers import CarAnchor
3
4
4
5
from util .ball_prediction_analysis import find_slice_at_time
5
6
from util .boost_pad_tracker import BoostPadTracker
@@ -46,6 +47,8 @@ def get_output(self, packet: GamePacket) -> ControllerState:
46
47
# By default we will chase the ball, but target_location can be changed later
47
48
target_location = ball_location
48
49
50
+ self .renderer .begin_rendering ()
51
+
49
52
if car_location .dist (ball_location ) > 1500 :
50
53
# We're far away from the ball, let's try to lead it a little bit
51
54
# self.ball_prediction can predict bounces, etc
@@ -65,10 +68,12 @@ def get_output(self, packet: GamePacket) -> ControllerState:
65
68
)
66
69
67
70
# Draw some things to help understand what the bot is thinking
68
- self .renderer .draw_line_3d (car_location , target_location , self .renderer .white )
71
+ self .renderer .draw_line_3d (
72
+ CarAnchor (self .index ), target_location , self .renderer .white
73
+ )
69
74
self .renderer .draw_string_3d (
70
75
f"Speed: { car_velocity .length ():.1f} " ,
71
- car_location ,
76
+ CarAnchor ( self . index ) ,
72
77
1 ,
73
78
self .renderer .white ,
74
79
)
@@ -78,9 +83,11 @@ def get_output(self, packet: GamePacket) -> ControllerState:
78
83
self .renderer .cyan ,
79
84
)
80
85
86
+ self .renderer .end_rendering ()
87
+
81
88
if 750 < car_velocity .length () < 800 :
82
89
# We'll do a front flip if the car is moving at a certain speed.
83
- return self .begin_front_flip (packet ) # type: ignore
90
+ return self .begin_front_flip (packet )
84
91
85
92
controls = ControllerState ()
86
93
controls .steer = steer_toward_target (my_car , target_location )
@@ -89,7 +96,7 @@ def get_output(self, packet: GamePacket) -> ControllerState:
89
96
90
97
return controls
91
98
92
- def begin_front_flip (self , packet : GamePacket ):
99
+ def begin_front_flip (self , packet : GamePacket ) -> ControllerState :
93
100
# Send some quickchat just for fun
94
101
# There won't be any content of the message for other bots,
95
102
# but "I got it!" will be display for a human to see!
@@ -109,7 +116,7 @@ def begin_front_flip(self, packet: GamePacket):
109
116
)
110
117
111
118
# Return the controls associated with the beginning of the sequence so we can start right away.
112
- return self .active_sequence .tick (packet )
119
+ return self .active_sequence .tick (packet ) # type: ignore
113
120
114
121
115
122
if __name__ == "__main__" :
0 commit comments