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
5 changes: 4 additions & 1 deletion RLBotPack/ElkBot/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,7 @@ dmypy.json
.pyre/

# VS Code
.vscode/
.vscode/

# Bot errors
.errors/
51 changes: 13 additions & 38 deletions RLBotPack/ElkBot/ExampleBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def initialize_agent(self):
super().initialize_agent()
self.state = None
self.do_debug = True
self.RTG_flip_time = 0

def run(self):
my_goal_to_ball, my_ball_distance = (self.ball.location-self.friend_goal.location).normalize(True)
goal_to_me = self.me.location-self.friend_goal.location
Expand Down Expand Up @@ -152,8 +154,17 @@ def run(self):
self.controller.boost = False if abs(angles[1]) > 0.5 or self.me.airborne else self.controller.boost
self.controller.handbrake = True if abs(angles[1]) > 2.8 else False
else:
if self.is_clear():
self.push(retreat())
if not (side(self.team) * self.me.location.y > 5120) and not (self.me.location-Vector(-893*sign(self.ball.location.x), 5000*side(self.team))).magnitude() < 200:
relative_target = Vector(-893*sign(self.ball.location.x), 5000*side(self.team)) - self.me.location
angles, vel = defaultDrive(self, 2300, self.me.local(relative_target))
if angles[1] < 0.75 and relative_target.magnitude() > 750 and 500 < self.me.velocity.magnitude() < 1000 and self.time - self.RTG_flip_time > 2:
self.push(flip(self.me.local(relative_target)))
self.RTG_flip_time = self.time
else:
self.controller.boost = False if abs(angles[1]) > 0.5 or self.me.airborne else self.controller.boost
self.controller.handbrake = True if abs(angles[1]) > 2.8 else False
else:
self.state += ' (In goal)'

if self.do_debug:
#this overdoes the rendering, needs fixing
Expand Down Expand Up @@ -213,42 +224,6 @@ def find_hits(self, targets, test_for_slow_ground_shots=True, test_for_slow_jump
output[name] = shot
return output

def get_tmcp_action(self):
if self.is_clear():
if 'RTG' in self.state:
return {
"type": "DEFEND"
}
return {
"type": "WAIT",
"ready": -1
}

stack_routine_name = self.stack[0].__class__.__name__

if stack_routine_name in {'Aerial', 'jump_shot', 'ground_shot', 'double_jump', 'short_shot'}:
return {
"type": "BALL",
"time": -1 if stack_routine_name == 'short_shot' else self.stack[0].intercept_time
}
if stack_routine_name == "goto_boost":
return {
"type": "BOOST",
"target": self.stack[0].boost.index
}

if stack_routine_name == 'retreat':
return {
"type": "WAIT",
"ready": -1
}

# by default, VirxERLU can't demo bots
return {
"type": "WAIT",
"ready": self.get_minimum_game_time_to_ball()
}

def get_minimum_game_time_to_ball(self):
shot = find_any_shot(self)
return -1 if shot is None else shot.intercept_time
6 changes: 6 additions & 0 deletions RLBotPack/ElkBot/custom_routines.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,32 @@ class speed_flip_kickoff:
def __init__(self):
self.old_boost = 34
self.stage = 0
print("Speedflipping!")

def run(self, agent: VirxERLU):
print("running speedflip routine")
if self.stage == 0:
agent.controller.boost = True
if agent.me.boost > self.old_boost:
self.stage = 1
agent.print(f"Next stage: {self.stage}")
else:
self.old_boost = agent.me.boost
elif self.stage == 1:
angles = defaultPD(agent, agent.me.local_location(Vector(110*sign(agent.me.location.x))))
if abs(angles[1]) < 0.1:
self.stage = 2
agent.print(f"Next stage: {self.stage}")
elif self.stage == 2:
agent.push(speed_flip())
self.stage = 3
agent.print(f"Next stage: {self.stage}")
elif self.stage == 3:
# TODO do a second flip is the opponent is speedflipping as well
if False:
agent.push(flip(agent.me.local_location(Vector(120*sign(agent.me.location.x)))))
self.stage = 4
agent.print(f"Next stage: {self.stage}")
elif self.stage == 4:
agent.pop()

4 changes: 2 additions & 2 deletions RLBotPack/ElkBot/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy
rlbot
VirxERLU-CLib>=1.15.2,<2.0.0
rlbot==1.*
VirxERLU-CLib==2.*
Loading