Skip to content

Commit 30cd12e

Browse files
committed
Goto_friendly_goal fix, tweaked onside and FormularBot now recognises non-stand kickoff positions.
Previouisly FormularBot would drive towards goal if abs(agent.me.location.y) < 5000. This was supposed to stop FormularBot moving when it reached its goal, however it also stopped FormularBot moving if it was in enemy goal. Now I have a separate check for blue team and orange team. The blue team one is if agent.me.location.y > -5000: Changed onside from me_onside = my_distance + 80 < my_ball_distance to 70 to hopefully stop FormularBot cancelling shots so much. elif x_position == 0: kickoff_position = 'back_centre' else: kickoff_position = 'unknown' ^ Next update FormularBot will have a fast back_centre kickoff which will be different from kickoffs for other gamemodes. FormularBot drifts if abs(angles[1]) > 1: while going centre.
1 parent 0575948 commit 30cd12e

File tree

3 files changed

+66
-14
lines changed

3 files changed

+66
-14
lines changed

DemoBot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ def run(agent):
1515
kickoff_position = 'back_left'
1616
elif x_position == 255 or x_position == 256:
1717
kickoff_position = 'back_right'
18-
else:
18+
elif x_position == 0:
1919
kickoff_position = 'back_centre'
20+
else:
21+
kickoff_position = 'unknown'
2022

2123
if agent.index == 0:
2224
agent.debug_stack()

FormularBot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def run(agent):
2020
my_goal_to_ball,my_ball_distance = (agent.ball.location - agent.friend_goal.location).normalize(True)
2121
goal_to_me = agent.me.location - agent.friend_goal.location
2222
my_distance = my_goal_to_ball.dot(goal_to_me)
23-
me_onside = my_distance + 80 < my_ball_distance
23+
me_onside = my_distance + 70 < my_ball_distance
2424

2525
close = (agent.me.location - agent.ball.location).magnitude() < 1500
2626
very_close = (agent.me.location - agent.ball.location).magnitude() < 500
@@ -69,8 +69,10 @@ def run(agent):
6969
kickoff_position = 'back_left'
7070
elif x_position == 255 or x_position == 256:
7171
kickoff_position = 'back_right'
72-
else:
72+
elif x_position == 0:
7373
kickoff_position = 'back_centre'
74+
else:
75+
kickoff_position = 'unknown'
7476

7577
#Shoots if onside and (closest to ball or ball within 4000 of foe goal and between -1250 and 1250 x or ball is within 3000 of own goal)
7678
if me_onside and (closest_to_ball or (distance_ball_foe_goal < 4000 and -1250 < agent.ball.location.x < 1250) or distance_ball_friendly_goal < 3000):

routines.py

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,29 @@ def run(agent):
3636
class goto_friendly_goal():
3737
#Drives towards friendly goal. If touching or over goal line stops moving and faces enemy goal
3838
def run(agent):
39-
if abs(agent.me.location.y) < 5000:
40-
relative = Vector3(0,5120*side(agent.team),0) - agent.me.location
41-
defaultPD(agent,agent.me.local(relative))
42-
angles = defaultPD(agent, agent.me.local(relative))
43-
if abs(agent.me.location.y) < 4900:
44-
defaultThrottle(agent,2300)
39+
if side(agent.team) == -1:
40+
if agent.me.location.y > -5000:
41+
relative = Vector3(0,5120*side(agent.team),0) - agent.me.location
42+
defaultPD(agent,agent.me.local(relative))
43+
angles = defaultPD(agent, agent.me.local(relative))
44+
if agent.me.location.y > -4900:
45+
defaultThrottle(agent,2300)
46+
else:
47+
relative = agent.foe_goal.location - agent.me.location
48+
defaultPD(agent,agent.me.local(relative))
49+
angles = defaultPD(agent, agent.me.local(relative))
4550
else:
46-
relative = agent.foe_goal.location - agent.me.location
47-
defaultPD(agent,agent.me.local(relative))
48-
angles = defaultPD(agent, agent.me.local(relative))
49-
51+
if agent.me.location.y < 5000:
52+
relative = Vector3(0,5120*side(agent.team),0) - agent.me.location
53+
defaultPD(agent,agent.me.local(relative))
54+
angles = defaultPD(agent, agent.me.local(relative))
55+
if agent.me.location.y < 4900:
56+
defaultThrottle(agent,2300)
57+
else:
58+
relative = agent.foe_goal.location - agent.me.location
59+
defaultPD(agent,agent.me.local(relative))
60+
angles = defaultPD(agent, agent.me.local(relative))
61+
5062
if abs(angles[1]) > 2.88 and abs(angles[1]) < 3.4:
5163
agent.push(half_flip())
5264

@@ -175,6 +187,9 @@ def run(agent):
175187
if relative_target.magnitude() > 350:
176188
defaultPD(agent, local_target)
177189
defaultThrottle(agent, 2300)
190+
if abs(angles[1]) > 1:
191+
agent.controller.handbrake = True
192+
agent.controller.boost = False
178193
else:
179194
#If close to target, stop moving and face towards ball
180195
defaultThrottle(agent, 0)
@@ -694,9 +709,42 @@ def run(self,agent):
694709
agent.controller.yaw = 0.85
695710
else:
696711
agent.controller.yaw = -0.85
697-
712+
713+
# elif self.kickoff == 'back_centre':
714+
# #Fast back_centre kickoff
715+
# defaultThrottle(agent,2300)
716+
# agent.controller.boost = True
717+
# if elapsed < 0.4:
718+
# relative_target = agent.ball.location - agent.me.location
719+
# local_target = agent.me.local(relative_target)
720+
# defaultPD(agent,local_target)
721+
# if elapsed < 0.65:
722+
# relative_target = agent.boosts[31 if side(agent.team) == -1 else 2].location - agent.me.location
723+
# local_target = agent.me.local(relative_target)
724+
# defaultPD(agent,local_target)
725+
# if elapsed > 0.65 and elapsed < 0.7:
726+
# agent.controller.jump = True
727+
# elif elapsed > 0.65 and self.counter < 3:
728+
# agent.controller.jump = False
729+
# self.counter += 1
730+
# elif elapsed > 0.65 and self.counter < 4:
731+
# agent.controller.jump = True
732+
# agent.controller.pitch = -1
733+
# #Faces central
734+
# agent.controller.yaw = -1
735+
# self.counter += 1
736+
# elif self.counter == 4:
737+
# agent.controller.jump = False
738+
# self.counter += 1
739+
# elif self.counter > 4:
740+
# #Once landed flips into the ball
741+
# if not agent.me.airborne:
742+
# agent.push(flip(agent.me.local(agent.ball.location - agent.me.location)))
743+
# else:
744+
# agent.controller.yaw = -0.5
698745

699746
else:
747+
#kickoff for non-football gamemodes (heatseaker, dropshot etc) - just drives towards ball and flips
700748
target = agent.ball.location + Vector3(0,200*side(agent.team),0)
701749
local_target = agent.me.local(target - agent.me.location)
702750
defaultPD(agent, local_target)

0 commit comments

Comments
 (0)