Make target dice sequence a ping-pong triangle wave - #75
Merged
Conversation
The round target cycled 1→2→3→4→5→6→1, jumping from 6 back down to 1. Change it to climb and descend — 1,2,3,4,5,6,5,4,3,2,1,2,… — so the progression reads smoothly in both directions. The value alone can't encode direction (target 3 could be rising or falling), so derive it from round_num (a monotonic counter) as a triangle wave instead of from the previous target. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ug1kqfq8hC7G8PstttbzY8
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ug1kqfq8hC7G8PstttbzY8
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.
Problem
The round target cycled
1→2→3→4→5→6→1, jumping abruptly from 6 straight back down to 1 each time it wrapped. The progression should instead climb and descend smoothly —1,2,3,4,5,6,5,4,3,2,1,2,3,4,5,6,….Why the value-based approach couldn't work
A ping-pong sequence can't be derived from the current target value alone: when the target is
3, the next value could be2(descending) or4(ascending). The value carries no direction.Fix
Replaced
next_target(t)withtarget_for_round(round_num), which reads direction offround_num— a monotonic counter already tracked and incremented every round — as a triangle wave:Period 10. Round 1 maps to target 1, matching the value set at game creation, so the invariant holds from the first round.
advance_roundnow callstarget_for_round(old_round + 1).Changes
server/game.py— replacednext_targetwithtarget_for_roundserver/broadcast.py—advance_roundusestarget_for_round(old_round + 1)CLAUDE.md— updated the round-lifecycle descriptionVerification
Confirmed the generated sequence matches
1,2,3,4,5,6,5,4,3,2,1,2,…across 22 rounds and that both modules parse. No existing tests referenced the old function.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ug1kqfq8hC7G8PstttbzY8
Generated by Claude Code