A browser-based implementation of the ancient board game Go (Weiqi/Baduk) using Rust compiled to WebAssembly. Optimized for desktop, tablet, and mobile devices.
๐ฎ Play Online (GitHub Pages)
- ๐ฏ Full Go Gameplay: Complete rule implementation with capture mechanics
- ๐ฑ Mobile Optimized: Responsive design for phones and tablets with touch support
- โก Rust + WebAssembly: Fast, safe, and efficient game logic
- ๐ฒ Multiple Board Sizes: 9ร9, 13ร13, and 19ร19 boards
- ๐ Game History: Undo/redo functionality with state persistence
- โฏ๏ธ Pass Moves: Full game state management including pass functionality
- ๐พ URL State: Game state saved in URL for easy sharing and resuming
- ๐จ Touch-Friendly UI: Optimized buttons and interactions for mobile devices
- ๐ Cross-platform: Runs in any modern browser
- Rust (latest stable version)
- Modern web browser (Chrome, Firefox, Safari, Edge)
- No additional setup required - runs in any browser with WebAssembly support
-
Clone and enter the project directory:
cd rugo -
Build the project:
./build.sh
This will:
- Install
wasm-packif not present - Compile Rust to WebAssembly
- Generate JavaScript bindings
- Install
-
Serve the project:
python3 -m http.server 8000
Or if you have Node.js:
npm run serve
-
Open in browser: Navigate to
http://localhost:8000
This project is set up for automatic deployment to GitHub Pages using GitHub Actions.
-
Fork or clone this repository to your GitHub account
-
Enable GitHub Pages:
- Go to your repository settings
- Scroll to "Pages" section
- Under "Source", select "GitHub Actions"
-
Push to main branch:
git add . git commit -m "Initial commit" git push origin main
-
Automatic deployment:
- The GitHub Action will automatically build and deploy
- Your game will be available at
https://[YOUR-USERNAME].github.io/rugo/ - Build status can be seen in the "Actions" tab
If you prefer to deploy manually:
# Build the project
./build.sh
# The entire directory can be served as static files
# including index.html and the pkg/ folder- The WebAssembly files are built automatically by GitHub Actions
- No pre-built binaries are committed to the repository
- The deployment includes all necessary files for the game to run
- HTTPS is required for WebAssembly to work properly (GitHub Pages provides this)
rugo/
โโโ src/
โ โโโ lib.rs # Main game logic
โ โโโ shader.wgsl # WebGPU shaders
โโโ index.html # Web interface
โโโ build.sh # Build script
โโโ Cargo.toml # Rust dependencies
โโโ README.md # This file
- โ Canvas-based rendering (optimized for all devices)
- โ Complete Go rules (stone placement, capture, suicide prevention)
- โ Multiple board sizes (9ร9, 13ร13, 19ร19)
- โ Game history (undo/redo functionality)
- โ Pass moves (full turn management)
- โ Mobile optimization (responsive design, touch events)
- โ State persistence (URL-based game state saving)
- โ Touch-friendly interface (optimized for phones/tablets)
- โ Stone rendering (high-quality circular stones with proper styling)
- โ Capture detection (group capture with liberty calculation)
- โ Score tracking (capture count display)
- โ Error handling (invalid move detection and user feedback)
- Ko Rule Implementation: Prevent immediate recapture situations
- Game End Detection: Detect when both players pass consecutively
- Territory Scoring: Implement area counting for game end
- Visual Enhancements: Add animations and visual feedback
- AI Opponent: Basic computer player using simple heuristics
- Time Controls: Add game timers and time management
- Game Analysis: Move history viewer and game review features
To enable WebGPU in your browser:
- Chrome: Visit
chrome://flags/and enable "Unsafe WebGPU" - Firefox: Visit
about:configand setdom.webgpu.enabledtotrue - Safari: Use Safari Technology Preview
This is a learning project exploring WebGPU and Rust for game development. Contributions, suggestions, and improvements are welcome!
MIT License - feel free to use this code for your own projects.