Add WebSocket Bot Client#112
Merged
Merged
Conversation
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.
Closes #97
Summary
Implements a new
WebSocketBotClientclass that connects bot runners (NeuralNetBotRunner or RuleBasedBotRunner) to game servers via WebSocket for real-time gameplay. This component bridges the gap between bot inference logic and game server communication, enabling bots to join existing game rooms as real players. The client manages the WebSocket lifecycle, forwards game state updates to bot runners, and handles connection errors gracefully.Changes Made
bot2/
WebSocketBotClientclass in bot/service/websocket_bot.pystart(),stop(), andreset()methodsGameClientinto bot runner for action sendingBotRunnerProtocolfor duck typing support across bot runner typesWebSocketBotClientConfigdataclass for connection configurationbot/service/__init__.pypackage with proper exportsClaude Code Commands
/code-review-forwith comprehensive review process, severity categorization, and structured output format/generate-pr-summary-forwith detailed generation guidelines and quality checklist/implement-issuewith structured implementation process and validation steps/address-review-feedbackfor systematic resolution of code review issuesImplementation Details
RuleBasedOpponentpattern fromopponent_manager.pybut generalizes to support any bot runnerGameClientinClientMode.WEBSOCKETfor real-time communicationWebSocketBotClientcreates theGameClientand sets it on the runner'sclientattribute duringstart()type == "GameState"and uses the cached state fromclient._game_state_runningflag prevents processing messages afterstop()is calledrunner.on_game_state()calls in try/except to prevent bot errors from crashing the listenerTesting
stop()multiple times,reset()before start)player_id,is_connected) reflect correct stateAdditional Notes
GameClientand modelsBotRunnerProtocol(requiresclientattribute,on_game_state()method, andreset()method)