Skip to content

Commit

Permalink
(change Cyrus2D#14) Improved kick-off formation
Browse files Browse the repository at this point in the history
By simply changing the target position for the two most offending players, the problem in issue Cyrus2D#14 is fixed by this
  • Loading branch information
pilkiad committed Jan 18, 2025
1 parent 9c5b17f commit 0bfdf8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions base/formation_dt/setplay_our_formation.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ Ball 0 0
3 -15.33 3.66
4 -9.29 -15.12
5 -10.84 13.69
6 -0.71 -0.36
6 -10.71 -0.36
7 0 -6.97
8 0.48 6.73
9 13.69 -20.13
10 10.73 24
11 16.08 0
11 -16.08 0
----- 1 -----
Ball -54 0
1 -50 -0
Expand Down
7 changes: 5 additions & 2 deletions base/generator_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ def __init__(self):
self.min_opp_dist = 0.0

def calculate_min_opp_dist(self, wm: 'WorldModel' = None):
if wm is None or wm.opponents() is None or len(wm.opponents()) == 0:
try:
if wm is None or wm.opponents() is None or len(wm.opponents()) == 0:
return 0.0
return min([opp.pos().dist(self.target_ball_pos) for opp in wm.opponents() if opp is not None and opp.unum() > 0])
except:
return 0.0
return min([opp.pos().dist(self.target_ball_pos) for opp in wm.opponents() if opp is not None and opp.unum() > 0])

def evaluate(self, wm: 'WorldModel' = None):
self.min_opp_dist = self.calculate_min_opp_dist(wm)
Expand Down
3 changes: 3 additions & 0 deletions base/set_play/bhv_set_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def execute(self, agent: 'PlayerAgent'):

st = StrategyFormation.i()
target = st.get_pos(wm.self().unum())

if wm.game_mode().side() is wm.our_side():
nearest_tm_dist = 1000
nearest_tm = 0
Expand All @@ -50,8 +51,10 @@ def execute(self, agent: 'PlayerAgent'):
if dist < nearest_tm_dist:
nearest_tm_dist = dist
nearest_tm = i

if nearest_tm is wm.self().unum():
target = wm.ball().pos()

if GoToPoint(target, 0.5, 100).execute(agent):
agent.set_neck_action(NeckTurnToBallOrScan())
return True
Expand Down

0 comments on commit 0bfdf8d

Please sign in to comment.