Live data from Hacker News

2048 AI

ov3y.github.io

131–140 of 197 posts

Re: 2048 AI

#131
post #90
post #85

Earlier quoted context omitted.

Me too, I have this weird overlay of the game in my vision. It took a lot more of tetris to reach that effect.

All the fonts seem smaller, not sure if only one.

I'm getting the same thing. All the text in my Chrome window looks microscopic after playing.

Re: 2048 AI

#133
post #88

Earlier quoted context omitted.

The question is do you want to have the shortest expected number of turns until you win, or a 100% win rate. Playing safe (min-max) is what ensures the 100% win rate, but you might be making games longer on average.

It doesn't have a 100% win rate as it stands. Mini-max isn't even 'playing safe'. Consider the following choice of moves, each leading to one of 5 random tile inserts: Move A, which leads to 5 possible moves with the following game state goodnesses: ['Loss','Win','Win','Win','Win'] Move B, resulting in: ['99%CertainLoss','99%CertainLoss','99%CertainLoss','99%CertainLoss','99%CertainLoss'] Minimax is never going to ch…

Fair enough; I only ran it a couple times and it got to 2048 so I assumed it's a guaranteed win.

Re: 2048 AI

#134
post #87
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…

It did win for me on the first try: http://i.imgur.com/uMB2J7f.png

Won for me on the second run: http://i.imgur.com/zc0uNLz.png

Re: 2048 AI

#135
post #104

I'm consistently scoring higher than 2,500, and frequently as high as 3,500 with a tile of 512, by doing this: 1. Up 2. Right 3. Down 4. Left 5. Go to 1. That loop scores better than my trying.

I got up to 9,000 with: left, down, right, down, (repeat)

Not bad.

My new simple algo is:

1. Down until you cannot go down

2. Left

3. Down until you cannot go down

4. Right

5. Go to 1.

Re: 2048 AI

#136
post #43
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…

Heh. If you look in the code you'll see a big commented out chunk where I tried randomly sampling computer moves to get sort of an 'expected value' for the opposition's move. Empirically, it performed worse. 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. However I think there's some truth…

I was also working on a 2048 AI, but you beat me to it! Nice job.

I was at an early stage, my scoring is just the game score (which apparently is flawed!) so nothing fancy. My approach to the large branching factor with the random tiles was just to ignore them and continue the search with a random one until there are less than N tiles free (I empirically found 4/5 to be good), where I perform a full search and apply a simple mean to the resulting scores. Mine is not even minimax, just a simple depth-first search. It wins between 1/4 and 1/5 of the time in a small sample of 200 games, how does yours perform?

This would be a great AI competition! Too bad it takes so long to run lots of games (mine is ~10 turns a second).

I wonder if web workers would speed it up.

Re: 2048 AI

#137

BUG: Whenever two sets of tiles combine in a single move, only one of their scores is counted. For example, let's say that a pair of 8s and a pair of 4s are about to be combined into a new 16 tile and a new 8 tile. The game should be giving us 24 points total for this move because we are creating a 16 tile (16 pts) and an 8 tile (8 pts) where 8+16=24. However, this does not happen. Only one or the other combination w…

Ahh good catch. That got messed up during refactoring the original code. Thanks to the person who submitted the fix on github too.

Re: 2048 AI

#138
post #90
post #85

Earlier quoted context omitted.

Me too, I have this weird overlay of the game in my vision. It took a lot more of tetris to reach that effect.

All the fonts seem smaller, not sure if only one.

Assuming you mean all fonts everywhere, I got that too. I thought the next website I looked at went through some kind of redesign until I realized that the next two websites I looked at also looked like that.

Re: 2048 AI

#139
post #34
post #18

Earlier quoted context omitted.

I pressed solve from the start, and the AI lost.

This AI losing doesn't mean the game isn't winnable in principle. I don't know whether it is or not though.

Doesn't the fact that it's minimax mean that it's "unwinnable with sufficiently bad luck" though? I mean if there's a mistake in the AI it's that it assumes that the game is maliciously picking the worst possible tile placements. If it dropped those assumptions, then it would lose if the AI just happened to hit the "worst" placement every time by accident.

Re: 2048 AI

#140
I haven't read the source code yet, so this might be off right of the bat. But from the general knowledge of minmax I think the end-game code might need some tweaking.

If there is a guaranteed win, the algorithm will find it. However, if there isn't any, how does it pick a path when it thinks it will lose every time? Are all losses equal to each other? Are some better than the others? Could the elgorithm take the path with best chances where the most of the plays end up winning while only a few of them end up losing?

Post reply on HN