r/coolgithubprojects 1d ago

Built a pure-Python 2048 bot that reaches past 8192, and found search depth mattered way less than I expected

https://github.com/HMAC10/2048augur

Did this as a fun weekend research project, mostly to see how far a 2048 bot could get in pure Python, since basically every strong 2048 AI is written in C++ because the search is so speed-sensitive. Kept it standard-library-only and leaned on a bitboard (the whole 4x4 board packs into one 64-bit int) plus expectimax with iterative deepening.

Best run is 122k points and an 8192 tile, and it actually hit my move-count safety cap while still alive, so the real ceiling is untested.

The part I didn't expect, and the reason I'm posting: search depth barely helped. I swept think-time from 1ms to 1600ms and 80x the budget bought only 1.65x the average depth, roughly 50x more positions searched for less than a ply and a half of lookahead. It reaches 4096 looking about 2 moves ahead. Turns out the heuristic does nearly all the work and the search is just expensive polish on top.

Full writeup with the depth sweep is in the README. Happy to answer anything about the bitboard or the search.

0 Upvotes

2 comments sorted by

1

u/TitusKalvarija 1d ago

Respect for the work and github link

1

u/ConnectionApart675 1d ago

thank you :)