2048

SCORE
0

Use ↑ ↓ ← β†’ or W A S D to move Swipe to play!

πŸ€– AI Player

5 moves/sec
Loading AI model...
πŸ“š About the AI Bots

🎲 Random (Baseline)

Picks moves randomly from available legal directions. Used as a baseline to compare other strategies.

  • Average Score: ~1,000-2,000
  • Max Tile: Usually 128-256
  • Speed: Instant

⚑ Expectimax (Rust) - RECOMMENDED

Bitboard expectimax with a tuned heuristic. Uses pre-computed lookup tables for O(1) move operations and searches the game tree to maximize expected value.

  • Heuristic: Empty cells, available merges, monotonicity & tile-sum penalties
  • Search: Expectimax with depth adapting to board complexity
  • Result: Reliably reaches the 2048 tile (often 4096+)

🎲 MCTS (Monte Carlo)

Monte Carlo Tree Search β€” runs random rollouts from each possible move and picks the one with the highest average outcome.

  • Strategy: 200 random simulations per move
  • Max Tile: Typically reaches 1024-2048
  • Advantage: No training required, works immediately

🎯 DQN Shaped

Dueling Deep Q-Network trained with advanced reward shaping (corner bonus, monotonicity, empty cell incentives).

  • Training: 100,000 episodes via reinforcement learning
  • Architecture: Dueling DQN (512β†’512 shared, value/advantage streams)
  • Framework: PyTorch on Apple M4 GPU

πŸ–ΌοΈ CNN DQN

Dueling CNN that learns spatial patterns on the 4Γ—4 board with one-hot encoded tile channels.

  • Training: 100,000 episodes with reward shaping
  • Architecture: 3 conv layers (128ch + BatchNorm) + Dueling head
  • Advantage: Learns position-aware features automatically

πŸ”§ Implementation Details

Expectimax Rust: Uses bitboard representation (u64 with 4 bits per tile) and pre-computed lookup tables (65,536 entries) for instant move calculations β€” including a per-row heuristic table scoring empty cells, merges, monotonicity and tile sums. Search depth adapts to board complexity.

Risk-Averse Search: At chance nodes, blends average and minimum: (1-Ξ±)Γ—avg + Ξ±Γ—min where Ξ±=0.25, making moves more conservative.