A modern web implementation of the ancient Royal Game of Ur (c. 2500 BCE) with dual AI opponents, offline play, and animations. Built with Next.js, TypeScript, Rust, and WebAssembly.
rgou.tre.systems — works in any modern browser, no installation required.
- Dual AI: classic expectiminimax and a self-trained neural network, both running locally via WebAssembly
- Offline-first: a PWA that is fully playable without a connection
- Responsive UI: animations and sound effects on desktop and mobile
- Statistics: win/loss tracking persisted locally and saved to the database
- Node.js 20+ (download)
- Rust & Cargo (install) — compiles the AI to WebAssembly
- wasm-pack:
cargo install wasm-pack --version 0.12.1 --locked
Developed on Apple Silicon. It runs on other platforms, but ML training is tuned for Apple Silicon (see AI-SYSTEM.md).
git clone https://github.com/rgilks/rgou-cloudflare.git
cd rgou-cloudflare
npm install
npm run db:setup # local SQLite database
npm run build:wasm-assets # compile the Rust AI to WASM (required)
npm run devThe game opens at http://localhost:3000.
Two opponents, both running entirely in the browser:
- Classic AI (default): expectiminimax search with alpha-beta pruning and evolved genetic parameters.
- ML AI: a value + policy neural network trained through self-play.
See AI-SYSTEM.md for the algorithms, models, and training, and AI-MATRIX-RESULTS.md for win rates and speed.
npm run check # lint, type-check, Rust AI matrix, unit + e2e tests
npm run test # unit tests (Vitest)
npm run test:e2e # end-to-end tests (Playwright)
npm run test:ai-comparison:fast # quick AI comparisonSee DEVELOPMENT.md for the full command reference and troubleshooting.
- ARCHITECTURE.md — system design, data flow, database, and deployment
- AI-SYSTEM.md — Classic AI, ML AI, training, and genetic evolution
- AI-MATRIX-RESULTS.md — generated AI win-rate and speed results
- DEVELOPMENT.md — commands, testing, and troubleshooting
- GAME-GUIDE.md — rules, strategy, and history
- TODO.md — roadmap
- ml/README.md — ML training quick start
- worker/rust_ai_core/tests/README.md — Rust test suite
- Frontend: Next.js, React, TypeScript, Tailwind CSS, Framer Motion, Zustand
- AI engine: Rust compiled to WebAssembly, running in Web Workers
- Database: Cloudflare D1 (production), SQLite (development), Drizzle ORM
- Deployment: Cloudflare Workers via OpenNext, deployed by GitHub Actions
See ARCHITECTURE.md for details.
MIT — see LICENSE.
- Irving Finkel — British Museum curator who reconstructed the rules
- RoyalUr.net — game analysis and strategy
- The Rust and WebAssembly communities
