Conversation
… number of kicks PenaltyRef::penalty_check_score() ended the shootout with `M_pen_nr_taken > 2 * (pen_max_extra_kicks + pen_nr_kicks)`, i.e. after 2 * (nr + extra) + 1 kicks: the team that kicked first took one attempt more than the other, the second team's last kick was never taken, and the referee then announced penalty_draw (or a coin toss) on an unequal number of attempts. With the defaults (5 + 5) that is 11 kicks against 10. The exhaustion check now runs only after an even number of kicks, at `>= 2 * (nr + extra)`, and only while the teams are level; when the score differs after the last pair the existing branches name the winner as before. With 5 + 5 the shootout now ends after exactly 10 kicks each. Also handle pen_nr_kicks = 0 and pen_max_extra_kicks = 0: the score check only runs after a kick, so both teams used to take one kick each before the draw/coin toss. startPenaltyShootout() now decides right away. Reported upstream to rcsoccersim/rcssserver by the FoxLeague owner (unmerged); the same condition is in rcssserver master and 19.0.0. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 048f871)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
PenaltyRef::penalty_check_score()(src/referee.cpp) ends the shootout withThe sudden-death branch below it (
> 2 * nr, only on even counts, only when the score differs) never triggers at2 * (nr + extra)when the teams are level, so nothing else stops the extra kick.Second, smaller case: with
pen_nr_kicks=0andpen_max_extra_kicks=0the score check only runs after a kick, so both teams still took one kick each before the decision.Fix
% 2 == 0and>=: evaluated only after both teams completed the same number of attempts, ending after exactlynr + extrakicks each (10 with the defaults).startPenaltyShootout(): whenpen_nr_kicks + pen_max_extra_kicks <= 0callpenalty_check_score()right away, which with 0 kicks taken and 0-0 goes straight to the draw / coin toss.No behaviour change for a shootout decided before the exhaustion point, and no change to the "cannot win any more" early termination.
pen_max_extra_kicks=6is not needed to get 11 kicks per team with this fix:nr + extrais now exactly the number of kicks per team, so 5 + 6 gives 11 each, 5 + 5 gives 10 each.Verification (headless, this branch vs. master, same harness)
Harness: one
rcssserver(auto_mode,synch_mode,penalty_shoot_outs=on,pen_nr_kicks=2,pen_max_extra_kicks=2,pen_dist_x=10,player_rand=ball_rand=kick_rand=0), 5 field players + 1 goalie per side as plain UDP clients, 2 x 2 s halves ending 0-0. Each taker runs to the ball duringpenalty_setup, the referee snaps it to 2 m at the setup timeout, then it dashes and kicks to the far post (scores) unless told to miss. Play modes are the referee messages heard by the clients; "Score:" lines are the server's own stderr.master (unpatched), all kicks score
RIGHT (kicked first) took a 9th kick, LEFT never answered, referee said
penalty_drawwith a 4-5 penalty score.this branch, all kicks score
Ends after 8 kicks, equal attempts, the second team's last kick (
penalty_score_rat 676) is recorded.this branch,
pen_random_winner=onthis branch, LEFT misses its 4th kick (score differs after the last pair)
penalty_winner_rat 8, not a draw; the master control run on the same scenario also givespenalty_winner_rafter 8, so the winner path is unchanged.zero kicks configured (
pen_nr_kicks=0,pen_max_extra_kicks=0)Built with CMake (Release) on Ubuntu 24.04, Boost 1.83.
Release path (not done here)
🤖 Generated with Claude Code
Fixes the off-by-one left by #126 (the branch reorder kept the strict
>). The same change was verified headlessly with scripted clients atpen_nr_kicks=2,pen_max_extra_kicks=2: before, the shootout ended 4-5 after 9 kicks withpenalty_draw; after, it ends 4-4 after 8 with both teams' kicks recorded, a missed kick still yieldspenalty_winner, andpen_nr_kicks=0withpen_max_extra_kicks=0goes straight to the draw/coin toss.