Durak-online, a remodel of my previous durak
A browser-based implementation of MCTS to guide gameplay in the card game Durak, with a clean web UI.
Toggle Computer Shuffle in the header to switch between modes:
- Computer Shuffle ON — Play against AI opponents. The computer deals the cards and you play against MCTS or random players. Toggle for real game help.
- Computer Shuffle OFF — Get help in a real-life game. Input the cards you see and the actions opponents take, and the AI suggests your optimal moves. Toggle to play vs computer.
This implements traditional Durak with optional reflecting rules:
- Support for 2-6 players and deck sizes from 32 to 52 cards
- The attacker can only attack with one card at a time (irrelevant for gameplay if you think about it)
- Reflecting: Defender can pass the attack to the next player by playing a card of the same rank
- Trump reflecting: Defender can divert an attack by showing (not playing) a trump of the same rank. This can only be done once per trump per trick, and only if no card is defended yet.
- The starting player is determined by who has the lowest trump
| Type | Description |
|---|---|
| Human | Interactive gameplay through the UI |
| Random | Performs a random legal action |
| MCTS | Multi-threaded Determinized MCTS — samples possible card distributions and runs Monte Carlo tree search |
- Set Computer Shuffle to OFF (the default)
- Enter the trump card and your 6 starting cards
- Indicate each opponent's lowest trump (determines who starts)
- As the game progresses, select the actions opponents take
- When it's your turn, the AI shows win probabilities for each possible move
- Once the stock is empty and cards become deducible, opponent hands are revealed automatically
Configure Determinizations (number of random card distributions to sample) and Rollouts (MCTS simulations per distribution) to balance accuracy vs speed. Higher values = better AI but slower computation.
# Install wasm32 target (if using rustup)
rustup target add wasm32-unknown-unknown
# Install wasm-pack
cargo install wasm-pack# 1. Build the WASM module
cd durak-wasm
wasm-pack build --target web
cp pkg/durak_wasm* ../web/src/wasm/
# 2. Start the web app
cd ../web
npm install
npm run devThe app will be available at http://localhost:5173.
cd web
npm run build
# OR
npm run deploydurak3/
├── durak-core/ # Rust game engine (rules, state, MCTS)
├── durak-wasm/ # WebAssembly bindings
└── web/ # Svelte frontend
└── src/
├── App.svelte # Main UI
├── wasm/ # WASM module (generated)
└── workers/ # Web Workers for parallel MCTS