Skip to content

Claude/networkplay ai takeover yzrli#3

Merged
MostCromulent merged 7 commits intoNetworkPlayfrom
claude/networkplay-ai-takeover-Yzrli
Jan 21, 2026
Merged

Claude/networkplay ai takeover yzrli#3
MostCromulent merged 7 commits intoNetworkPlayfrom
claude/networkplay-ai-takeover-Yzrli

Conversation

@MostCromulent
Copy link
Owner

No description provided.

Add AI takeover functionality when players fail to reconnect:
- Convert timed-out player slots to AI type instead of removing them
- Substitute player controller with AI controller to maintain game state
- Preserve player's hand, library, and battlefield under AI control
- Resume game automatically once all disconnected players have AI takeover

Add /skipreconnect chat command for host:
- Allows host to skip 5-minute reconnection timer
- Can target specific player by name: /skipreconnect <playerName>
- Or affects first disconnected player if no name specified
- Only accessible to host player (index 0)
- Immediately triggers AI takeover for the disconnected player

Implementation details:
- Added convertPlayerToAI() method to handle controller substitution
- Uses Player.dangerouslySetController() to swap in AI controller
- Creates LobbyPlayerAi and PlayerControllerAi for disconnected player
- Updates lobby slot to AI type with " (AI)" suffix
- Marks player as connected in session after AI takeover
- Broadcasts informative messages to all players

This enhancement prevents games from becoming unplayable when a player
disconnects and allows the game to continue gracefully with AI control.
Improve documentation organization and clarity:
- Move AI takeover content from middle of Session Management to its own section after GUI Instance Management
- Fix section numbering (PlayerSession was incorrectly numbered as '2.' after interrupted flow)
- Update Disconnect Handling diagram to show AI takeover path
- Update reconnection timeline example to show correct AI takeover message
- Rename subsections for better clarity (e.g., 'Chat Command Handling' -> 'Implementation: Chat Command Parsing')
- Group all AI takeover content together: overview, host command, implementation details

The AI takeover feature is now presented in a logical flow after explaining the normal reconnection process, making it easier to understand as an extension of timeout handling.
Add new subsection 'AI-Assisted Debugging with Log Files' explaining how to use NetworkDebugLogger output with Claude for troubleshooting:

- How to locate and share log files
- What information to provide along with logs
- What types of issues Claude can help diagnose
- Tips for better analysis results (DEBUG level, timestamps, both client/server logs)
- Privacy considerations when sharing logs

This helps users leverage AI assistance for complex network synchronization issues that are difficult to debug manually.
- Add AI takeover description to reconnection support feature
- Add 'Additional Resources' section linking to debugging
- Mention comprehensive debug logging with AI-assisted troubleshooting
Remove references to AI-assisted troubleshooting as this is obvious to developers:
- Simplified overview debugging link to just mention 'comprehensive debug logging'
- Removed entire 'AI-Assisted Debugging with Log Files' section including:
  - How to use logs with Claude
  - Example usage
  - Tips for better results
  - Privacy note

The debug logging system and its usage is sufficiently documented in the existing sections.
- Change heading to 'Potential Future Improvements'
- Remove spectator reconnection item
- Renumber remaining improvements
@MostCromulent MostCromulent merged commit bd7960d into NetworkPlay Jan 21, 2026
@MostCromulent MostCromulent deleted the claude/networkplay-ai-takeover-Yzrli branch January 21, 2026 02:07
MostCromulent pushed a commit that referenced this pull request Jan 22, 2026
The issue was an ID collision in delta packet maps where PlayerView id=1
and CardView id=1 would overwrite each other, causing one object to be
lost during network synchronization.

Root cause:
- DeltaSyncManager uses Map<Integer, byte[]> for objectDeltas
- Map<Integer, NewObjectData> for newObjects
- Both maps key by object ID only, without considering type
- When PlayerView id=1 and CardView id=1 both exist, they collide

Solution:
- Added PLAYERVIEW_DELTA_KEY_OFFSET (Integer.MIN_VALUE + 1000)
- PlayerView deltas now use (OFFSET + playerId) as map key
- GameView already used INTEGER.MIN_VALUE (from bug #3 fix)
- CardView and other objects continue using actual IDs

This ensures each object type has a separate key space, preventing
collisions similar to the GameView fix in bug #3.

Files modified:
- DeltaSyncManager.java: Added offset constant and updated collectObjectDelta
- AbstractGuiGame.java: Updated applyDelta to handle PlayerView offset keys
- BUGS.md: Moved bug #4 to resolved bugs section
MostCromulent pushed a commit that referenced this pull request Feb 2, 2026
Creates comprehensive plan for splitting NetworkPlay branch into 5 PRs:
- PR #1: Delta Synchronization (keep on NetworkPlay/dev)
- PR #2: Reconnection Support (new branch)
- PR #3: Chat Improvements (new branch)
- PR #4: UI Improvements (new branch)
- PR #5: Testing Infrastructure (new branch)

Documents all 73 files with feature assignments, shared file surgery
strategy, and phased implementation procedure.

https://claude.ai/code/session_013JmPcURBTFDodDxioqFQ6G
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