Yahtzee CLI game in Go. Single binary with local AI play, MCP server for LLM integration, and P2P online play.
make check # Quick validation (vet + unit tests + build)
make test-short # Unit tests only (skips E2E)
make test-e2e # E2E tests only
make test-all # All tests with verbose output
make test-coverage # Unit tests with coverage report
make build # Build binary
make lint # Static analysis (go vet)
# AI Battle
yatz battle # Greedy vs Statistical (default)
yatz battle --players "A:llm:personas/aggressive.md,D:llm:personas/defensive.md"
yatz battle --rounds 100 --quiet # 100-game statistics- 開発中の変更確認:
make check— vet、ユニットテスト、ビルドを一括実行 - E2Eテスト:
make test-e2e— P2PやMCPの統合テスト。ネットワーク系の変更時に実行 - 全テスト:
make test-all— CIと同等の全テスト実行。PR作成前に推奨
-shortフラグ:testing.Short()でガードされたテストはユニットテスト時にスキップTestE2Eプレフィクス: E2EテストはTestE2E_で始める。-run TestE2Eで選択実行
cmd/yatz/ Entry point (cobra subcommands: play, mcp, host, join, match, battle)
engine/ Pure game logic (state machine, scoring, dice, AI, Strategy, Battle, GameClient interface)
cli/ Interactive TUI (bubbletea v2) + AI battle spectator
mcp/ MCP server for LLM integration (mcp-go, stdio transport)
p2p/ P2P host-authority online play (length-prefixed JSON over TCP)
match/ Matchmaking WebSocket client
lambda/ Serverless matchmaking handler (AWS Lambda + API Gateway + DynamoDB)
bot/ LLM bot integration (MCP config, system prompt, Claude API, LLM Strategy)
personas/ Markdown-based AI persona definitions for LLM Strategy
- GameClient interface (
engine/client.go): abstracts local vs remote game access.LocalClientwrapsGamefor local play;RemoteClient(p2p/guest.go) communicates over TCP. - State machine: 4 phases —
PhaseWaiting,PhaseRolling,PhaseChoosing,PhaseFinished. Transitions enforced inengine/game.go. - Player IDs: Use hyphens (
player-0,player-1), not underscores. - Host-authority model: Host runs the game engine; guest sends actions over TCP and receives state updates.
- AI auto-play:
LocalClient.Score()triggers AI turns automatically viarunAITurns(). - Scorecard:
map[Category]*intwherenil= unfilled,*0= filled with zero. - Strategy pattern (
engine/strategy.go):Strategyinterface abstracts AI decision-making. Implementations:GreedyStrategy(immediate best score),StatisticalStrategy(expected value),LLMStrategy(Claude API viaanthropic-sdk-go). - Battle engine (
engine/battle.go):RunBattle()drives AI-vs-AI games.OnTurnDonecallback streams results to TUI spectator. - LLM API Key:
LLMStrategycalls Claude API directly (not via MCP) for speed. Uses--api-keyflag orANTHROPIC_API_KEYenv var.
cobra— CLI frameworkcharm.land/bubbletea/v2— TUI frameworkmark3labs/mcp-go— MCP servergorilla/websocket— matchmaking clientaws-lambda-go,aws-sdk-go-v2— serverless matchmakinganthropic-sdk-go— Claude API client for LLM Strategystretchr/testify— test assertions