mirror of
https://github.com/imjasonh/uno
synced 2026-07-06 22:52:55 +00:00
No description
- Fix npm test to exclude e2e Playwright tests (only run unit/integration) - Add seed=42 to e2e tests for deterministic bot names and winner - Fix unit tests to reset pendingDraw state after manual game setup - Make stacking integration test deterministic using seed 2 All tests now pass consistently without flakiness. Signed-off-by: Jason Hall <jason@chainguard.dev> |
||
|---|---|---|
| .github/workflows | ||
| dist | ||
| src | ||
| test | ||
| web | ||
| .gitignore | ||
| bugs.txt | ||
| learnings.md | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| playwright.config.js | ||
| prompt.md | ||
| README.md | ||
| rules.md | ||
| simulate.js | ||
| vite.config.js | ||
UNO Game Simulation
A JavaScript UNO card game implementation with bot players, pluggable strategies, CLI simulation, and web UI.
Note
This project was vibe-coded largely over two hours in one sitting, on YouTube livestream
Web UI
Play UNO in your browser with an interactive web interface.
Quick Start
# Install dependencies
npm install
# Start development server
npm run dev
Then open http://localhost:5173 in your browser.
Production Build
# Build optimized production bundle
npm run build
# Preview production build
npm run preview
The production build outputs to dist/ with optimized assets (~55KB gzipped). The preview server runs on http://localhost:4173.
Features
- Spectator Mode: Watch bots play automatically
- Human Player Mode: Play against bots with full UI interaction
- 2-6 Players: Configurable player count with flexible positioning
- Wild Card Selection: Color picker modal for wild cards
- Special Cards: Skip, Reverse, Draw Two/Four with visual indicators
- Animation Controls: Toggle between instant and smooth animations
- Game Statistics: Winner display and Play Again functionality
Testing
# Run all E2E tests
npm run test:e2e
# Run against production build
BASE_URL=http://localhost:4173 npm run test:e2e
CLI Simulation
Run headless game simulations from the command line.
Quick Start
# Run a 2-player game
node simulate.js
# Run with 4 players
node simulate.js --players 4
# Verbose output showing each turn
node simulate.js --players 4 --verbose
# Run with multiple games
node simulate.js --count 10
Run Unit Tests
npm test
Project Structure
src/game/- Core game logic (Card, Deck, Player, Game, Rules)src/strategies/- Bot AI strategies (BasicStrategy)src/report/- Game statistics and reportingsimulate.js- CLI entry pointtest/unit/- Unit tests for all componentstest/integration/- Full game simulation testsreports/- Generated JSON reports from simulations
Implementation Details
Game Rules:
- 2-6 players, 7 cards dealt to each
- Match by color or value
- Action cards: Skip, Reverse, Draw Two, Wild, Wild Draw Four
- Stacking: +2 stacks on +2 only, +4 stacks on +4 only (no cross-stacking)
- Win by emptying your hand
Architecture:
- ES modules (Node.js)
- Strategy pattern for bot AI (easily extensible)
- Event-driven game loop for observability
- Automatic deck reshuffling when draw pile exhausted
- Full test coverage with Node.js built-in test runner
Reports:
Generated after each game in reports/report.json with:
- Turn count and duration
- Winner
- Per-player stats (cards played/drawn, UNOs called, action/wild cards played)
Game Rules
See rules.md for complete UNO rules including stacking mechanics and edge cases.