A classic Tetris game enhanced with AI capabilities. Watch the AI play automatically using a heuristic-based algorithm, or connect to Claude API for AI-powered gameplay!
Features
- Classic Tetris Gameplay: Full implementation with SRS rotation, hold piece, and 6-piece preview
- Local AI: Heuristic-based AI with configurable weights and 2-step lookahead
- Claude AI Mode: Optional integration with Anthropic’s Claude API
- Human-like Animation: Configurable think time and move delays
- Weight Presets: Balanced, Conservative, and Aggressive play styles
- Ghost Piece: Shows AI’s planned final position
How to Play
Manual Play
Use keyboard controls:
- Arrow Keys: Move left/right/down
- Space: Hard drop
- X/Z: Rotate right/left
- C: Hold piece
- R: Retry
- Esc: Pause
AI Auto-play
- Check “Enable AI Auto-play” on the main menu
- Click “Play Sprint” or “Play Dig Race”
- Watch the AI play!
AI Settings
Click “AI Weights Settings” to configure:
- Weight Presets: Choose Balanced, Conservative, or Aggressive
- Think Time: Add human-like delays
- Move Delay: Control animation speed
- Hard Drop: Toggle between hard drop and soft drop
Claude AI Mode
Want to see Claude play Tetris?
- Open AI Settings
- Enable “Use Claude AI”
- Enter your Anthropic API key
- Select a model (Sonnet 4 recommended)
- Watch Claude analyze the board and decide each move!
Play Now
How the AI Works
The AI evaluates each possible piece placement using 10 features:
- Landing height, rows cleared, transitions, holes, wells, bumpiness, and more
With 2-step lookahead, it considers both the current piece and the next piece in the preview queue to make smarter decisions.
For Claude AI mode, the board state is converted to text and sent to Claude, which responds with rotation count and target position.
Technical Details
- Built with vanilla JavaScript and HTML5 Canvas
- No external dependencies (except optional Claude API)
- All calculations run locally in your browser
- View documentation
Enjoy watching the AI stack!