55from rlbot .utils .structures .game_data_struct import GameTickPacket
66from rlbot .utils .structures .quick_chats import QuickChats
77
8+ from util .goal_detector import find_future_goal
89from util .orientation import Orientation
10+ from util .sequence import Sequence , ControlStep
911from util .spikes import SpikeWatcher
1012from util .vec import Vec3
11- from util .sequence import Sequence , ControlStep
1213
1314
1415class MyBot (BaseAgent ):
@@ -25,13 +26,13 @@ def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
2526 return self .active_sequence .tick (packet )
2627
2728 self .spike_watcher .read_packet (packet )
28-
2929 ball_prediction = self .get_ball_prediction_struct ()
30+
31+ # Example of predicting a goal event
3032 predicted_goal = find_future_goal (ball_prediction )
3133 goal_text = "No Goal Threats"
32-
3334 if predicted_goal :
34- goal_text = f"Goal in { '%.4s' % str ( predicted_goal [ 1 ] - packet .game_info .seconds_elapsed ) } s"
35+ goal_text = f"Goal in { predicted_goal . time - packet .game_info .seconds_elapsed :.2f } s"
3536
3637 ball_location = Vec3 (packet .game_ball .physics .location )
3738 my_car = packet .game_cars [self .index ]
@@ -101,13 +102,3 @@ def draw_debug(renderer, text_lines: List[str]):
101102 renderer .draw_string_2d (50 , y , 1 , 1 , line , renderer .yellow ())
102103 y += 20
103104 renderer .end_rendering ()
104-
105-
106- def find_future_goal (ball_predictions ):
107- for i in range (0 , ball_predictions .num_slices ):
108- # field length(5120) + ball radius(93) = 5213 however that results in false positives
109- if abs (ball_predictions .slices [i ].physics .location .y ) >= 5235 :
110- # returns the position the ball crosses the goal as well as the time it's predicted to occur
111- return [Vec3 (ball_predictions .slices [i ].physics .location ), ball_predictions .slices [i ].game_seconds ]
112-
113- return None
0 commit comments