Skip to content

Confirm and close issue #5: CopperBot head-on collision avoidance#11

Merged
revodavid merged 1 commit intomainfrom
copilot/fix-server-issue-5
Mar 11, 2026
Merged

Confirm and close issue #5: CopperBot head-on collision avoidance#11
revodavid merged 1 commit intomainfrom
copilot/fix-server-issue-5

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

Issue #5 requested difficulty-scaled head-on collision behavior for CopperBot. The feature was already fully implemented in v3.6.0 — this PR confirms it's working as specified.

Verified behavior

Collision tile scoring in calculate_move() across all difficulty levels:

Level Behavior
1 Always avoid predicted opponent head tile
2–5 Avoid with probability 90%→10% (interpolated); otherwise seek
6–9 Seek if my_length > opp_length, probability 10%→90%; otherwise avoid
10 Always seek if longer; always avoid if not
# Level 6–9 core logic
prioritize_prob = 0.1 + (self.difficulty - 6) * 0.8 / 3
if my_length > opp_length and random.random() < prioritize_prob:
    score += collision_bonus   # 2000
else:
    score += collision_penalty # -5000

Simulation over 200 trials per level confirmed empirical rates match the specified probabilities. Already documented in CHANGELOG under v3.6.0.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh issue list --repo revodavid/copperhead-server (http block)
    • Triggering command: /usr/bin/gh gh auth status (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

confirm server issue #5 is fixed, updated and close if so

[Chronological Review] 1. User requested "launch-game" → skill loaded, server and client launched on ports 8765 and 3000 2. User requested 2 instances of sleepy-snake → found bot at copperhead-server/bot-library/sleepy_snake.py, launched both, they played and finished 3. User requested 2 instances of sleepy-snake level 1 → launched with --difficulty 1, observed stalemate trigger 4. User asked why stalemate took ~90s instead of 30s → investigated code, explained that accidental food collection resets the timer (ticks_since_last_collection * tick_rate >= game_timeout) 5. User requested changelog update and push to v401 → fixed dates from 2026-06-26 to 2026-03-10, added missing entries (Sleepy Snake bot, competition status messaging), pushed both repos 6. User requested UX fix for disqualification message → traced server->client flow, found server sends close code 4008, client showed "Disconnected" instead of descriptive message 7. First fix attempt: added 4008 handler in connectWebSocket's onclose → tested but still showed "Disconnected from lobby" because players join via joinLobby() which has its own onclose handler 8. Second fix: added 4008 handler to lobby's onclose handler → tested, user confirmed it works, pushed to v401 9. User requested fix for server issue #10 (stale playfield) → investigated, found root cause: client doesn't clear gameState on match_assigned, server doesn't send initial game state 10. Fixed both server (include game state in match_assigned) and client (clear/render fresh state on match_assigned) 11. Relaunched to test → both services running, awaiting user testing

[Intent Mapping]

  • "launch-game" → launch CopperHead server and client locally
  • "launch 2 instances of sleepy-snake" → run bot instances
  • "launch 2 instances of sleepy-snake level 1" → run L1 difficulty bots (food-avoiding)
  • "why did it take so long?" → explain stalemate timing
  • "update the changelog and push to v401 branch" → update both changelogs, commit and push
  • "when a human is disqualified..." → fix disqualification UX (status message + button text)
  • "relaunch locally to test" → restart server/client to test changes
  • "Fix server issue Playfield in stale state before round start #10" → fix stale playfield before round start
  • "relaunch to test" → restart server/client to test issue Playfield in stale state before round start #10 fix

[Technical Inventory]

  • CopperHead: multiplayer snake game with server (Python/FastAPI/WebSocket) and client (JavaScript)
  • Repos: copperhead-server (revodavid/copperhead-server) and copperhead-client (revodavid/copperhead-client)
  • Branch: v401 for both repos
  • Server: Python, FastAPI, Uvicorn, WebSocket on port 8765
  • Client: Static JS served via python -m http.server on port 3000
  • Local settings: server-settings.local.json (20x16 grid, 0.04s tick, 2 points to win, 0 bots, auto-start: always)
  • Bots: sleepy_snake.py in bot-library/, copperbot.py, murderbot.py
  • Close code 4008: custom WebSocket code for ready timeout
  • Game stalemate: ticks_since_last_collection * config.tick_rate >= config.game_timeout

[Code Archaeology]

  • copperhead-server/main.py: Game class (line 962), GameRoom class (line 1205), _handle_ready_timeout (line 1278), connect_competition_player (line 1329), broadcast_state (line 1696), game_loop (line 1543), start_game (line 1507), _start_next_game (line 1670)
  • copperhead-client/game.js: connectWebSocket onclose (line 737), joinLobby onclose (line 1729), match_assigned handler (line 1039), sendReady (line 1187), updateCanvas (line 1325), "Return to Lobby" pattern (line 1189)
  • copperhead-server/bot-library/sleepy_snake.py: wandering bot with difficulty 1-10
  • copperhead-server/CHANGELOG.md: updated v4.0.1 date and entries
  • copperhead-client/CHANGELOG.md: updated v4.0.1 date and entries

[Progress Assessment]

[Context Validation]

[Recent Commands Analysis]

  • Last commands: Relaunched server and client for issue Playfield in stale state before round start #10 testing
  • Server started (PID 31484 on port 8765), client started (PID 51156 on port 3000)
  • Admin token: 5e344adf250f9e5b
  • User needs to test that playfield shows correct dimensions and starting snake heads before clicking "Start Round"
1. Conversation Overview: - Primary Objectives: Launch and test CopperHead snake game locally; fix UX issues including disqualification messaging and stale playfield rendering (GitHub issue #10); update changelogs and push to v401 branch - Session Context: The session involved iterative development on the CopperHead multiplayer snake gam...

Created from Copilot CLI via the copilot delegate command.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix server issue #5 and update disqualification message Confirm and close issue #5: CopperBot head-on collision avoidance Mar 11, 2026
@revodavid revodavid marked this pull request as ready for review March 11, 2026 01:02
@revodavid revodavid merged commit f624373 into main Mar 11, 2026
1 check 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