# A more "human" 2048 AI

## What's this all about?

I've seen a few different AI solvers for 2048, but none of them really seem, for lack of a better work, relatable. The
most iconic AI for 2048 is probably [the one developed by Matt Overlan](http://ov3y.github.io/2048-AI), which is really
well designed and very interesting when you look at the nuts and bolts of how it works; however, if you're just watching
it play through, this stategy appears distinctly inhuman. My goal was to develop an AI that plays the game more
similarly to how I've seen actual humans play.

## How does each strategy work?

### Random

This is does exactly what you think it does; it just moves randomly. Needless to say, this is not a tremendously
effective stategy, but it's a good baseline. And, to be fair, I've seen a few people who seem to use this as their
primary stategy...

### Corner

This strategy is just about packing everything into one corner. The basic idea here is a solid foundation—trying to let
larger tiles sift down to a designated corner—but this algorithm is pretty dumb and has no way to adapt to changing
conditions; it just blindly throws all the tiles to the bottom-right and hopes for the best. I've seen several players
rely largely on this strategy until the board starts filling up.

### Greedy

The "greedy" strategy behaves in the way that I've probably seen most people play—thinking two moves into the
future. This algorithm calculates which series of two moves will result in the highest score, and then
proceeds to make the first of those moves. After this, it will reevaluate based on the new tile that has been placed
on the board, but will often proceed with the second move it originally planned.

While it's not the best algorithm, it's not terrible. I've only seen it get to 2048 once, but it often makes it to 1024.
I think this mirrors the experience of a lot of players who use this strategy.

### Patient

This strategy represents the player who understands, unlike our "greedy" player, the value of
delayed satisfaction. Rather than simply looking at how many points can be earned in the next couple of moves, this
algorithm attempts to prepare "chains" of ascending tiles. As the board fills up, this strategy will be more likely to
try to combine tiles, rather than lengthen these chains.

Additionally, this strategy will avoid moving up, only doing so when no other moves are possible, which allows the
larger tiles to sift down to the bottom of the board.

### Cautious

Finally, we have the "cautious" strategy, a hybrid of the previous three strategies. Like the "corner" strategy, this
strategy will do its best to keep the highest value tile in the bottom-right corner. In addition, it will "imagine" each
possible move and evaluate based on both the "chains" of tiles that move produces and the points that move could earn,
and weighs its options.

Like the "patient" strategy, this one only moves upward as a last resort, but it also goes one step further. As
any of you who have tried a similar strategy know, sometimes a new tile will appear in a place that makes it
impossible for you to move any direction other than up. Before performing a move, this strategy checks if that move
could potentially leave it open to this tragic scenario. While it can't avoid it 100% of the time, it does a pretty
good job.
