1
0
Fork 0
mirror of https://github.com/imjasonh/uno synced 2026-07-06 22:52:55 +00:00
No description
Find a file
Jason Hall 0111223d10 Fix flaky tests and add deterministic seeding
- 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>
2026-01-20 10:00:22 -05:00
.github/workflows deploy to GitHub Pages 2026-01-16 19:23:24 -05:00
dist Add base path for GitHub Pages deployment 2026-01-16 19:25:13 -05:00
src Fix flaky tests, game restart bugs, and screenshot reproducibility 2026-01-20 09:46:35 -05:00
test Fix flaky tests and add deterministic seeding 2026-01-20 10:00:22 -05:00
web Fix flaky tests, game restart bugs, and screenshot reproducibility 2026-01-20 09:46:35 -05:00
.gitignore
bugs.txt Fix flaky tests, game restart bugs, and screenshot reproducibility 2026-01-20 09:46:35 -05:00
learnings.md Fix flaky tests, game restart bugs, and screenshot reproducibility 2026-01-20 09:46:35 -05:00
LICENSE
package-lock.json
package.json Fix flaky tests and add deterministic seeding 2026-01-20 10:00:22 -05:00
playwright.config.js Fix flaky tests, game restart bugs, and screenshot reproducibility 2026-01-20 09:46:35 -05:00
prompt.md fix "back" bug 2026-01-20 09:18:54 -05:00
README.md add yt link 2026-01-16 19:21:04 -05:00
rules.md
simulate.js
vite.config.js Add base path for GitHub Pages deployment 2026-01-16 19:25:13 -05:00

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 reporting
  • simulate.js - CLI entry point
  • test/unit/ - Unit tests for all components
  • test/integration/ - Full game simulation tests
  • reports/ - 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.