Skip to content

tre-systems/rgou-cloudflare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

415 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Royal Game of Ur

CI/CD

rgou Screenshot
Buy Me a Coffee at ko-fi.com

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.

Play Now

rgou.tre.systems — works in any modern browser, no installation required.

Features

  • 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

Quick Start

Prerequisites

  • 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).

Setup

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 dev

The game opens at http://localhost:3000.

AI System

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.

Testing

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 comparison

See DEVELOPMENT.md for the full command reference and troubleshooting.

Documentation

Architecture

  • 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.

License

MIT — see LICENSE.

Acknowledgments

  • Irving Finkel — British Museum curator who reconstructed the rules
  • RoyalUr.net — game analysis and strategy
  • The Rust and WebAssembly communities