feat: AI vs AI battle with multiple strategies - #17
Merged
Merged
Conversation
Implement Strategy interface and three AI strategies (Greedy, Statistical, LLM) with a battle orchestration system. The StatisticalStrategy evaluates all 32 hold combinations using expected value calculation, significantly outperforming Greedy. - Add Strategy interface and TurnAction type (engine/strategy.go) - Extract GreedyStrategy from existing bestCategory logic - Add StatisticalStrategy with expected value calculation - Add RunBattle orchestrator for automated AI-vs-AI games - Add `yatz battle` command with quiet and TUI spectator modes - Add LLMStrategy using anthropic-sdk-go for Claude API calls - Add persona system for LLM character customization - Add sample personas (aggressive, defensive, gambler) - Refactor AIPlayer to support Strategy and hold loop - Extend AITurnResult with StrategyName and HoldHistory
When a Strategy returns "hold" after all rolls are used, PlayTurn now falls back to best available category instead of passing an empty category to Score(). Also deduplicates GreedyStrategy logic by reusing bestCategoryForDice.
…te LLM hold indices Add empty-slice fallback in bestCategoryForDice to prevent panic. Reject LLM hold actions with empty indices to avoid unintended full rerolls.
…ject docs Add comprehensive documentation for the AI Battle feature: - Design spec covering Strategy pattern, battle engine, TUI spectator - Implementation plan with completed phases and future extensions - Update CLAUDE.md with bot/, personas/, Strategy pattern, battle commands - Update README.md with AI Battle section, commands, and persona guide
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.
Summary
yatz battleコマンドで AI 同士を対戦させ、TUI で観戦 or quiet モードで統計表示Usage
Changes
Strategyinterface,TurnActiontypeRunBattleオーケストレーターAITurnResultにStrategyName,HoldHistory追加yatz battleコマンド(quiet/TUI 両対応)Test plan
make check— 既存テスト全通過、ビルド成功go test ./engine/ -run TestStatistical— 期待値計算テストgo test ./engine/ -run TestRunBattle— バトルオーケストレーションテストyatz battle --players "G:greedy" --players "S:statistical" --quiet— quiet モード動作確認yatz battle --players "G:greedy" --players "S:statistical" --rounds 100 --quiet— 統計モード確認yatz battle --players "G:greedy" --players "S:statistical" --speed 500ms— TUI 観戦確認ANTHROPIC_API_KEY=... yatz battle --players "G:greedy" --players "Claude:llm"— LLM 対戦確認