Skip to content

Implement the proposed new penalty shootout format

Hannes Braun requested to merge penalty-shootout-2023 into devel

How it works

The PenaltyShootout variable can be used to enable penalty shootouts.

A kicker and a goalie from both teams join simultaneously. (4 players in total are on the field.) The kicker is expected to beam behind the ball. The minimum distance is specified through PenaltyShootoutBehindBallDistance. If the player doesn't obey this, he will be automatically moved far enough away from the ball. The ball position is specified with PenaltyShootoutBallDistance.

When the game is started by switching the play mode to KickOff_Left, the kicker from the left team has to kick towards the right goal. With KickOff_Right, it's the other way around. The active kicker is only allowed to touch the ball once. When the ball is touched, the play mode is changed to PlayOn until a goal is scored (at which point the play mode changes to Goal_<Left or Right>). If

  • the player wasn't able to score in time (see parameter PenaltyShootoutMaxTime),
  • the player touched the ball for a second time,
  • the ball is not moving anymore (speed < 0.002),
    the play mode will be set to BeforeKickOff.

After RuleGoalPauseTime, the play mode will be automatically switched to KickOff_<Left or Right> and it's the other kickers turn. Goalies are still not allowed to move outside of the penalty area. The game ends after a specified minimum amount of rounds (PenaltyShootoutMinRounds) if one team scores more goals than the other team. After a specified maximum number of rounds (PenaltyShootoutMaxRounds), the game will be over regardless of the score.

Some notes

Although this implementation should work in general, I'm not entirely happy with it as the SoccerRuleAscpect class is growing more and more, and it's probably becoming more difficult to maintain. In the future, we should try to refactor this class by splitting it up and trying to de-duplicate some code. I didn't want to do that in this merge request already, as the diff would otherwise be really hard to read. Also, it's not priority number one right now. (First, we need to get all the desired features implemented for this year.)

Also, we might introduce special play modes in the future for the penalty shootout instead of reusing the existing ones. That might help clean up the implementation. Also, it would get us closer to running an entire game (two regular halves as well as the two extra halves and the penalty shootout in the case of an elimination round) in one session (no server restart, no reconnecting of the agents).


If you have any questions, let me know. Any kind of feedback is appreciated :)

Closes #46 (closed)

Merge request reports