Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Include everything the framework requires
# You will automatically get updates for all versions starting with "1.".
rlbot==1.*
rlbot_gui
rlbottraining

# This will cause pip to auto-upgrade and stop scaring people with warning messages
Expand Down
11 changes: 0 additions & 11 deletions run.bat

This file was deleted.

5 changes: 0 additions & 5 deletions run.sh

This file was deleted.

7 changes: 7 additions & 0 deletions run_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from rlbot_gui import gui

# This is a useful way to start up RLBotGUI directly from your bot project. You can use it to
# arrange a match with the settings you like, and if you have a good IDE like PyCharm,
# you can do breakpoint debugging on your bot.
if __name__ == '__main__':
gui.start()
36 changes: 36 additions & 0 deletions src/util/spikes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from rlbot.utils.structures.game_data_struct import PlayerInfo, GameTickPacket

from util.vec import Vec3

# When the ball is attached to a car's spikes, the distance will vary a bit depending on whether the ball is
# on the front bumper, the roof, etc. It tends to be most far away when the ball is on one of the front corners
# and that distance is a little under 200. We want to be sure that it's never over 200, otherwise bots will
# suffer from bad bugs when they don't think the ball is spiked to them but it actually is; they'll probably
# drive in circles. The opposite problem, where they think it's spiked before it really is, is not so bad because
# they usually spike it for real a split second later.
MAX_DISTANCE_WHEN_SPIKED = 200

class SpikeWatcher:
def __init__(self):
self.carrying_car: PlayerInfo = None
self.spike_moment = 0
self.carry_duration = 0

def read_packet(self, packet: GameTickPacket):
ball_location = Vec3(packet.game_ball.physics.location)
closest_candidate: PlayerInfo = None
closest_distance = 999999
for i in range(packet.num_cars):
car = packet.game_cars[i]
car_location = Vec3(car.physics.location)
distance = car_location.dist(ball_location)
if distance < MAX_DISTANCE_WHEN_SPIKED:
if distance < closest_distance:
closest_candidate = car
closest_distance = distance
if closest_candidate != self.carrying_car and closest_candidate is not None:
self.spike_moment = packet.game_info.seconds_elapsed

self.carrying_car = closest_candidate
if self.carrying_car is not None:
self.carry_duration = packet.game_info.seconds_elapsed - self.spike_moment