https://github.com/yuanx749/2048-ai-tk
2048 AI in Python with GUI.
https://github.com/yuanx749/2048-ai-tk
2048 game gui pep8 project pytest
Last synced: 5 months ago
JSON representation
2048 AI in Python with GUI.
- Host: GitHub
- URL: https://github.com/yuanx749/2048-ai-tk
- Owner: yuanx749
- License: mit
- Created: 2019-12-28T12:58:49.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-20T11:47:21.000Z (over 2 years ago)
- Last Synced: 2025-06-27T09:08:08.040Z (5 months ago)
- Topics: 2048, game, gui, pep8, project, pytest
- Language: Python
- Homepage: https://yuanx749.github.io/2048-ai-tk/
- Size: 89.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 2048-ai-tk
[](https://app.codacy.com/gh/yuanx749/2048-ai-tk/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
## Description
- Minimax with alpha–beta pruning and iterative deepening, ~90% win rate.
- Tkinter GUI, no additional package required on Windows.
- Can switch between automatic and manual modes.
```bash
sudo apt install python3-tk # for Linux
python game.py
```
## Implementation
Modules:
- `grid.py`: Contains class that represents the 2048 board.
- `game.py`: Driver that runs the game in GUI.
- `minimax.py`: Minimax implementation, reusable in other games.
- `player_ai.py`: Minimax for 2048.
Optimizations:
- Order nodes to maximize pruning.
- Memorization in iterative deepening.
Some heuristics:
- available cells
- potential merging
- average, median, max tile
- difference between adjacent tiles
- score and penalty of ordering across rows, columns
---
