Skip to content

Add BotPlayer abstract base class#157

Open
markrcote wants to merge 6 commits intomainfrom
claude/add-bot-framework-sV9Fj
Open

Add BotPlayer abstract base class#157
markrcote wants to merge 6 commits intomainfrom
claude/add-bot-framework-sV9Fj

Conversation

@markrcote
Copy link
Owner

Introduce a BotPlayer ABC that extends Player with an is_bot flag and
two abstract strategy methods: decide_bet() and decide_action(). This
provides the extension point for creating bots with custom blackjack
strategies. Also add is_bot = False to the base Player class to allow
distinguishing human players from bots.

https://claude.ai/code/session_01YTW8VfUgRq4x174iQYoBJc

Introduce a BotPlayer ABC that extends Player with an is_bot flag and
two abstract strategy methods: decide_bet() and decide_action(). This
provides the extension point for creating bots with custom blackjack
strategies. Also add is_bot = False to the base Player class to allow
distinguishing human players from bots.

https://claude.ai/code/session_01YTW8VfUgRq4x174iQYoBJc
Implement a concrete BotPlayer that uses a simple dealer-aware strategy:
- Always bets the minimum amount
- Against a weak dealer card (2-6): stands on 12+ to let the dealer bust
- Against a strong dealer card (10/face/ace): hits below 17
- Against a moderate dealer card (7-9): hits below 17

https://claude.ai/code/session_01YTW8VfUgRq4x174iQYoBJc
During the BETTING phase, bots automatically place bets via their
decide_bet() strategy method. During the PLAYING phase, if the current
player is a bot, their decide_action() method is called to determine
whether to hit or stand, and the action is executed immediately.

Human player behavior is unchanged — they still get turn reminders
and interact via Redis messages.

https://claude.ai/code/session_01YTW8VfUgRq4x174iQYoBJc
Add add_bot() and remove_bot() methods to Casino for managing bot
players in games. Bots are created from a registry of available bot
types (currently just 'simple'). A new 'bot_action' event type in the
Redis message protocol allows adding/removing bots via pub/sub with
messages like:

  {"event_type": "bot_action", "game_id": "...",
   "action": "add_bot", "bot_name": "...", "bot_type": "simple"}

https://claude.ai/code/session_01YTW8VfUgRq4x174iQYoBJc
Test coverage for:
- BotPlayer ABC cannot be instantiated directly
- Player.is_bot vs BotPlayer.is_bot identity
- SimpleBlackjackBot strategy decisions (strong/weak/moderate dealer cards)
- Bot auto-betting during BETTING phase tick
- Bot auto-playing during PLAYING phase tick
- Bot hitting on low scores across multiple ticks
- Complete bot game lifecycle (WAITING through BETWEEN_HANDS)
- Bot and human player coexistence in the same game
- Casino.add_bot/remove_bot management methods
- BOT_TYPES registry validation

https://claude.ai/code/session_01YTW8VfUgRq4x174iQYoBJc
Add 'addbot' and 'removebot' commands to the CLI client:
- addbot [name] [type] — adds a bot to the current game
  (name and type are optional, defaults to auto-generated name
  and 'simple' strategy)
- removebot <name> — removes a bot from the current game

Both commands send bot_action events via Redis to the server.

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

Comments