Skip to content

Commit fba5c4e

Browse files
committed
Changed some decision making, DemoBot bug fix, added distance_ball_foe_goal variable, bug fix go_to_friendly_goal and description change
Replaced uses of if agent.ball.location.y * side(agent.team) * -1 > x * side(agent.team) * -1 or similar, which only worked for blue team, with if distance_ball_foe/friendly_goal. Changed shooting range to 4000 and x to 1250. Changed clearing range to 3000. Changed closet o 1500 Added stack == 'getting boost' and agent.me.boost < 20 as a condition to not clear stack because often bot would not have any boost because it kept clearing stack everytime it tried to get some. Now it doesn't clear stack unless low on boost. Since I removed all stack clearing code from routines.py I forgot to update DemoBot to not send True as a variable when pushing demo_nearest_enemy to stack. Also added a try, except, which says no enemies to Demo :( Removed defaultThrottle(agent.0) from goto_friendly_goal as something to do when reaching it as that's not needed and probably stops car from turning around from momentum. Added 'Plays best in 3s.' to description as mode of FormularBots team code is written for 3s for when it played in Ultimate Battle League.
1 parent 51e4beb commit fba5c4e

File tree

4 files changed

+32
-31
lines changed

4 files changed

+32
-31
lines changed

DemoBot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ def run(agent):
1111
if agent.kickoff_flag:
1212
agent.push(kickoff(int(agent.me.location.x * side(agent.team))))
1313
else:
14-
agent.push(demo_enemy_closest_ball(True))
14+
agent.push(demo_enemy_closest_ball)

FormularBot.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ maximum_tick_rate_preference = 120
1616
# These values are optional but useful metadata for helper programs
1717
developer = FormularSumo
1818

19-
description = A bot named after me, based on GoslingUtils. Started 1 April.
19+
description = A bot named after me, based on GoslingUtils. Plays best in 3s. Started 1 April.
2020

2121
fun_fact = It was originally created in Scratch then ported to Python (1 day in)
2222

FormularBot.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
class FormularBot(GoslingAgent):
1515
def run(agent):
1616
global stack
17-
relative_target = agent.ball.location - agent.friend_goal.location
18-
distance_ball_friendly_goal = relative_target.magnitude()
17+
distance_ball_friendly_goal = (agent.ball.location - agent.friend_goal.location).magnitude()
18+
distance_ball_foe_goal = (agent.ball.location - agent.foe_goal.location).magnitude()
1919

2020
if len(agent.foes) > 0:
2121
enemies = agent.foes
@@ -36,7 +36,7 @@ def run(agent):
3636
my_distance = my_goal_to_ball.dot(goal_to_me)
3737
me_onside = my_distance + 80 < my_ball_distance
3838

39-
close = (agent.me.location - agent.ball.location).magnitude() < 1000
39+
close = (agent.me.location - agent.ball.location).magnitude() < 1500
4040
very_close = (agent.me.location - agent.ball.location).magnitude() < 500
4141
distance_to_ball = (agent.me.location - agent.ball.location).flatten().magnitude()
4242
distance_to_friendly_goal = (agent.me.location - agent.friend_goal.location).flatten().magnitude()
@@ -74,7 +74,7 @@ def run(agent):
7474

7575

7676

77-
if me_onside and (closest_to_ball or (agent.ball.location.y * side(agent.team) * -1 > 2500 * side(agent.team) * -1 and agent.ball.location.x < 1500 and agent.ball.location.x > -1500)):
77+
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):
7878
shooting = True
7979
else:
8080
shooting = False
@@ -85,20 +85,18 @@ def run(agent):
8585
goalie = False
8686

8787
# if agent.index == 0:
88-
# agent.debug_stack()
89-
# print(shooting,goalie)
90-
# agent.line(Vector3(1500,3000,50),Vector3(-1500,3000,50),[0,255,255])
91-
# print(closest_to_ball)
92-
# print(distance_to_ball,closest_ally_to_ball_distance)
93-
# print(close)
94-
# print(me_onside)
95-
# print(distance_ball_friendly_goal)
96-
# agent.line(agent.foe_goal.left_post,agent.foe_goal.right_post)
97-
# print(Vector3(agent.ball.location))
98-
# print(closest_ally_friendly_goal_distance,distance_to_friendly_goal)
99-
# agent.line(agent.friend_goal.location, agent.ball.location, [255,255,255])
100-
# my_point = agent.friend_goal.location + (my_goal_to_ball * my_distance)
101-
# agent.line(my_point - Vector3(0,0,100), my_point + Vector3(0,0,500), [0,255,0])
88+
# agent.debug_stack()
89+
# print(shooting,goalie)
90+
# print(closest_to_ball)
91+
# print(distance_to_ball,closest_ally_to_ball_distance)
92+
# print(close)
93+
# print(me_onside)
94+
# agent.line(agent.foe_goal.left_post,agent.foe_goal.right_post)
95+
# print(Vector3(agent.ball.location))
96+
# print(closest_ally_friendly_goal_distance,distance_to_friendly_goal)
97+
# agent.line(agent.friend_goal.location, agent.ball.location, [255,255,255])
98+
# my_point = agent.friend_goal.location + (my_goal_to_ball * my_distance)
99+
# agent.line(my_point - Vector3(0,0,100), my_point + Vector3(0,0,500), [0,255,0])
102100

103101
if len(agent.stack) < 1:
104102
if agent.kickoff_flag and closest_to_ball:
@@ -135,7 +133,7 @@ def run(agent):
135133
stack = 'getting boost'
136134
agent.push(get_nearest_big_boost)
137135

138-
if not stack == kickoff and not(stack == 'shooting' and (close and (agent.me.airborne or me_onside or agent.me.location.y * side(agent.team > 2500 * -side(agent.team))))):
136+
if not stack == kickoff and not(stack == 'shooting' and (close and (agent.me.airborne or me_onside or distance_ball_foe_goal < 3500))) and not(stack == 'getting boost' and agent.me.boost < 20):
139137

140138
if agent.kickoff_flag and closest_to_ball:
141139
if stack != 'kickoff':

routines.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def run(agent):
4545
relative = agent.foe_goal.location - agent.me.location
4646
defaultPD(agent,agent.me.local(relative))
4747
angles = defaultPD(agent, agent.me.local(relative))
48-
defaultThrottle(agent,0)
4948

5049
if abs(angles[1]) > 2.88 and abs(angles[1]) < 3.4:
5150
agent.push(half_flip())
@@ -109,16 +108,20 @@ def run(agent):
109108
if agent.me.boost < 10:
110109
agent.push(get_nearest_big_boost)
111110
else:
112-
relative_target = agent.foes[y].location - agent.me.location
113-
local_target = agent.me.local(relative_target)
114-
defaultPD(agent, local_target)
115-
defaultThrottle(agent, 2300)
116-
distance_remaining = local_target.flatten().magnitude()
111+
try:
112+
relative_target = agent.foes[y].location - agent.me.location
113+
local_target = agent.me.local(relative_target)
114+
defaultPD(agent, local_target)
115+
defaultThrottle(agent, 2300)
116+
distance_remaining = local_target.flatten().magnitude()
117+
118+
if distance_remaining < 2000 or agent.me.boost > 50 and distance_remaining < 5000:
119+
agent.controller.boost = True
120+
else:
121+
agent.controller.boost = False
122+
except:
123+
print('There are no enemies to demo :(')
117124

118-
if distance_remaining < 2000 or agent.me.boost > 50 and distance_remaining < 5000:
119-
agent.controller.boost = True
120-
else:
121-
agent.controller.boost = False
122125

123126
class half_flip():
124127
def __init__(self):

0 commit comments

Comments
 (0)