Live data from Hacker News

2048 AI

ov3y.github.io

61–70 of 197 posts

Re: 2048 AI

#61

I've been playing this for awhile now and I think I have found that the best method is to only use 3 directions. This forces your highest number into a corner and only spawns 2's and 4's in the opposite corner. You build up numbers that cascade down to the corner. It almost never gets stuck, but if you do I guess you'd have to push the 4th direction you haven't been using.

That's what I have been doing. It "feels" like a good strategy.

But I couldn't tell if it was really just for my own cognitive convenience. That is, it's easier for me to reason about moves if I constrain moves to keep my high tiles against an edge.

I watched the AI play once, and it of course does not constrain itself this way. To really rub it in, the AI won the game, which I have not.

Re: 2048 AI

#62
Nice job on the AI! I can still do much better much quicker by hand using the left-down-right-down-left-... strategy. Obviously an alpha-beta search should be able to do better than that naive strategy, but it needs a little more domain knowledge.

Re: 2048 AI

#63
post #59

I've been playing this for awhile now and I think I have found that the best method is to only use 3 directions. This forces your highest number into a corner and only spawns 2's and 4's in the opposite corner. You build up numbers that cascade down to the corner. It almost never gets stuck, but if you do I guess you'd have to push the 4th direction you haven't been using.

I won with using basically this strategy. I was forced to use the other direction exactly once. http://i.imgur.com/4Ig74Q9.jpg

Likewise, I wouldn't say I only used the other direction only once, but I definitely keep the highest tile in the top right, and build up the top row, mostly moving up and right only

Re: 2048 AI

#64

I've been playing this for awhile now and I think I have found that the best method is to only use 3 directions. This forces your highest number into a corner and only spawns 2's and 4's in the opposite corner. You build up numbers that cascade down to the corner. It almost never gets stuck, but if you do I guess you'd have to push the 4th direction you haven't been using.

I won 4 times in a row using a variant of that strategy where I lined up biggest to smallest numbers in a snake like pattern across the bottom of the grid. I only used up if my largest number got moved from the corner and I only used left if my bottom row was completely filled or my choices were narrowed to up or left.

EDIT: 5 times in a row now. I think I'm addicted.

EDIT: lost on my attempt for 6 in a row. I had to press up right after the 1024 appeared and was scrambling the rest of the game. I managed to get the 512 and 2 256s to appear as well but couldn't get them together.

Re: 2048 AI

#65
Lovely! Creating something like this was my initial reaction after seeing 2048, too :-)

An ideal mini-project and good PR for an entry level AI dev. Or, indeed, for a post-exit AI dev...

Re: 2048 AI

#66
I think that the scoring system can be improved. This AI wins with a lot less moves than me, hence it gets lower score for a solution "smarter" than mine.

Re: 2048 AI

#67
post #38

The AI implements minimax using alpha-beta pruning. Minimax assumes that the game/computer which the AI is playing against is playing adversarially - i.e. that the computer will insert the new tile that's the worst possible tile for the player/AI to receive. But that's not actually what the game is doing. Instead, new tiles are inserted randomly. As a result, minimax probably isn't the best approach here. I think som…

Its not always winning, but it does sometimes win. Is this game even winnable with every possible prng seed? I wouldn't be surprised if there were guaranteed-loss states.

Re: 2048 AI

#68
post #53
post #48

Earlier quoted context omitted.

Its interesting that your approach performed worse; I wonder if it could be modified to do better? Interesting. >I think this is for the same reason that all minimax algos assume optimal play by the opponent: if you assume optimal and they play less than so, it can only work in your favor. That doesn't make sense when talking about a random opponent, though. Imagine its chess. You are considering moving a pawn into a…

When playing against a random opponent, sometimes it will "accidentally" make the best possible move. In chess, this might be extremely unlikely, as there are so many possible moves: the probability that, of all the pieces on the board, with all of the positions it could have made, that it would stumble upon a move that devastates your position--especially considering that often multiple correct moves must be perform…

It sounds like you're thinking he suggested just greedily taking the best possible move. But that's not what he suggested; he suggested evaluating the actual distribution of the opponent's moves and making the move with the highest expected value.

Re: 2048 AI

#70
post #68
post #53

Earlier quoted context omitted.

When playing against a random opponent, sometimes it will "accidentally" make the best possible move. In chess, this might be extremely unlikely, as there are so many possible moves: the probability that, of all the pieces on the board, with all of the positions it could have made, that it would stumble upon a move that devastates your position--especially considering that often multiple correct moves must be perform…

It sounds like you're thinking he suggested just greedily taking the best possible move. But that's not what he suggested; he suggested evaluating the actual distribution of the opponent's moves and making the move with the highest expected value.

No, I entirely understood that. I am quite happily willing to believe that I misunderstand the ramifications of that algorithm (I spent a lot of time talking about game theory in college, but it was not my field, and that was a long time ago), but that is the algorithm I inferred. (I would respond more, but you didn't leave me with any specific complaints to respond to, so all I can really say is "no".)
Post reply on HN