Skip to content

Make target dice sequence a ping-pong triangle wave - #75

Merged
radiantnode merged 2 commits into
mainfrom
claude/target-dice-sequencing-hn9bv2
Jul 18, 2026
Merged

Make target dice sequence a ping-pong triangle wave#75
radiantnode merged 2 commits into
mainfrom
claude/target-dice-sequencing-hn9bv2

Conversation

@radiantnode

Copy link
Copy Markdown
Owner

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 be 2 (descending) or 4 (ascending). The value carries no direction.

Fix

Replaced next_target(t) with target_for_round(round_num), which reads direction off round_num — a monotonic counter already tracked and incremented every round — as a triangle wave:

def target_for_round(round_num: int) -> int:
    m = (round_num - 1) % 10
    return m + 1 if m <= 5 else 11 - m

Period 10. Round 1 maps to target 1, matching the value set at game creation, so the invariant holds from the first round. advance_round now calls target_for_round(old_round + 1).

Changes

  • server/game.py — replaced next_target with target_for_round
  • server/broadcast.pyadvance_round uses target_for_round(old_round + 1)
  • CLAUDE.md — updated the round-lifecycle description

Verification

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

claude added 2 commits July 18, 2026 01:10
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
@radiantnode
radiantnode merged commit 76cc229 into main Jul 18, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants