feat: Implement basic bot AI for game actions including mulligan, playing lands, casting creatures, and declaring attackers.
This commit is contained in:
@@ -5,3 +5,4 @@
|
||||
|
||||
## Devlog Index
|
||||
- [Enable Clear Session](./devlog/2025-12-20-014500_enable_clear_session.md) - Improved UI/UX for session clearing in CubeManager.
|
||||
- [Bot Actions](./devlog/2025-12-22-114000_bot_actions.md) - Implemented simple bot AI for playing lands, casting creatures, and passing priority.
|
||||
|
||||
29
docs/development/devlog/2025-12-22-114000_bot_actions.md
Normal file
29
docs/development/devlog/2025-12-22-114000_bot_actions.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Bot Logic Implementation
|
||||
|
||||
## Changes
|
||||
- **Client/Server Types**: Added `isBot` to `PlayerState` interface.
|
||||
- **GameManager**:
|
||||
- Updated `createGame` to persist `isBot` flag from room players.
|
||||
- Implemented `processBotActions` method:
|
||||
- **Mulligan**: Always keeps hand.
|
||||
- **Main Phase**: Plays a Land if available and not played yet.
|
||||
- **Main Phase**: Casts first available Creature card from hand (simplified cost check).
|
||||
- **Combat**: Attacks with all available creatures.
|
||||
- **Default**: Passes priority.
|
||||
- Added `triggerBotCheck` public method to manually trigger bot automation (e.g. at game start).
|
||||
- Updated `handleStrictAction` to include a `while` loop that processes consecutive bot turns until a human receives priority.
|
||||
- **Server Entry (index.ts)**:
|
||||
- Injected `gameManager.triggerBotCheck(roomId)` at all game start points (Normal start, Solo test, Deck timeout, etc.) to ensure bots act immediately if they win the coin flip or during mulligan.
|
||||
|
||||
## Bot Behavior
|
||||
The bots are currently "Aggressive/Linear":
|
||||
1. They essentially dump their hand (Lands -> Creatures).
|
||||
2. They always attack with everything.
|
||||
3. They never block.
|
||||
4. They pass priority instantly if they can't do anything.
|
||||
|
||||
## Future Improvements
|
||||
- Implement mana cost checking (currently relying on loose engine rules or implicit valid state).
|
||||
- Implement target selection logic (currently casting only if no targets needed or using empty array).
|
||||
- Implement blocking logic.
|
||||
- Implement "Smart" mulligans (currently always keep).
|
||||
Reference in New Issue
Block a user