https://github.com/zsc/gp_2048_demo
https://github.com/zsc/gp_2048_demo
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zsc/gp_2048_demo
- Owner: zsc
- Created: 2025-07-16T02:33:49.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-07-22T08:50:23.000Z (8 months ago)
- Last Synced: 2025-07-22T10:41:26.940Z (8 months ago)
- Language: OCaml
- Size: 416 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 2048 Genetic Programming Solver (OCaml)
An OCaml implementation of a 2048 game solver using expectimax search and genetic programming, achieving 30-40x performance improvement over Python.
## Web Interface
The project includes a Flask web app with OCaml backend for fast AI inference:
```bash
# Run the web server
cd python && python app.py
# Visit http://localhost:5000
```
Features:
- Train GP models via web UI
- Play 2048 with OCaml-powered AI (30-40x faster than Python)
- Real-time inference time display
## Directory Structure
- **lib/** - Core library (game engine, GP trees, expectimax)
- **experiments/** - Various experiments and analysis
- **benchmarks/** - Performance comparison tools
- **python/** - Original Python implementation
- **results/** - Experiment results and leaderboards
- **tests/** - Test data and controlled experiments
- **archive/** - Old/deprecated code
## Quick Start
```bash
# Build everything
dune build
# Run main program
dune exec gp_2048
# Test score-based strategy (best performer)
dune exec ./test_score_based.exe
# Run experiments
cd experiments && dune exec ./experiment_node_limited.exe
```
## Key Results
**Best Strategy**: Score-based dynamic node allocation
- Average score: 8,788
- Speed: 11.4 games/sec
- Adapts computation based on game progress
See CLAUDE.md for detailed documentation and results.