def place_ball(self, game: g.Game): """ Place the ball when kicking. """ left_center = m.Square(7, 8) right_center = m.Square(20, 8) if game.is_team_side(left_center, self.opp_team): return m.Action(t.ActionType.PLACE_BALL, pos=left_center) return m.Action(t.ActionType.PLACE_BALL, pos=right_center)
def high_kick(self, game: g.Game): """ Select player to move under the ball. """ ball_pos = game.get_ball_position() if game.is_team_side(game.get_ball_position(), self.my_team) and \ game.get_player_at(game.get_ball_position()) is None: for player in game.get_players_on_pitch(self.my_team, up=True): if m.Skill.BLOCK in player.skills: return m.Action(t.ActionType.PLACE_PLAYER, player=player, pos=ball_pos) return m.Action(t.ActionType.SELECT_NONE)
def setup(self, game: g.Game): """ Move players from the reserves to the pitch """ i = len(game.get_players_on_pitch(self.my_team)) reserves = game.get_reserves(self.my_team) if i == 11 or len(reserves) == 0: return m.Action(t.ActionType.END_SETUP) player = reserves[0] y = 3 x = 13 if game.is_team_side(m.Square(13, 3), self.my_team) else 14 return m.Action(t.ActionType.PLACE_PLAYER, player=player, pos=m.Square(x, y + i))
def reverse_x_for_left(game: g.Game, team: m.Team, x: int) -> int: if game.is_team_side(m.Square(13, 3), team): res = game.state.pitch.width - 1 - x else: res = x return res