Live data from Hacker News

2048 AI

ov3y.github.io

11–20 of 197 posts

Re: 2048 AI

#11

That's awesome. I'm looking at the source code but I can't seem to grasp it. What's a simple explanation of how it works?

Sorry, the code is a little unkempt.

The basic idea is minimax search. Googling that will get you started, but basically the algorithm plays out the game and keeps a score of the position after every move. Then it just makes the move that leads to the best score.

The "score" here is basically a count of how many free squares there are (with a little extra to keep things aligned if possible).

One major thing with these search algorithms is that the game tree grows exponentially as you move forward. To combat that, implemented alpha-beta pruning and a heuristic to only search the nastier computer moves rather than all of the possibilities.

Re: 2048 AI

#13
Oh well, I lost with AI as well. I just let it run and got to a game over with 8476 points.

Re: 2048 AI

#19
post #11

That's awesome. I'm looking at the source code but I can't seem to grasp it. What's a simple explanation of how it works?

Sorry, the code is a little unkempt. The basic idea is minimax search. Googling that will get you started, but basically the algorithm plays out the game and keeps a score of the position after every move. Then it just makes the move that leads to the best score. The "score" here is basically a count of how many free squares there are (with a little extra to keep things aligned if possible). One major thing with thes…

Awesome, thanks for that! I was going to try when I saw the thread earlier but couldn't figure out how.
Post reply on HN