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

Corner-locked expectimax with bitboards. Uses pre-computed lookup tables for O(1) move operations and searches the game tree to maximize expected value.

  • Strategy: Keeps max tile in top-left corner using snake pattern
  • Search: Expectimax with iterative deepening (depth 2-8)
  • Performance: 10-30x faster than JavaScript version

🎯 DQN Shaped

Deep Q-Network trained with reward shaping to encourage good behaviors (empty tiles, high tiles, corner positioning).

  • Training: 50,000 episodes via reinforcement learning
  • Architecture: MLP (256→128 hidden units)
  • Framework: PyTorch on Apple M4 GPU

🖼️ CNN DQN

Convolutional Neural Network that learns spatial patterns on the 4×4 board.

  • Training: 25,000 episodes (in progress)
  • Architecture: 2 conv layers (64 channels) + FC (128 units)
  • 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. The gradient heuristic uses powers of 12 to strongly prefer snake-pattern tile arrangements.

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