Skip to content

imjasonh/uno

Repository files navigation

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.

About

UNO card game with bot AI strategies, playable in browser or CLI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors