Wednesday, April 23, 2014

2048

Ever since I got my Android, I haven't really looked at the play store. I figure I might as well see games other people made. The top one on the list is a game called 2048. I downloaded it yesterday, and I couldn't stop playing it. I just had to beat this thing. I can see it's smug face laughing at me. Hell no. Anyway, I did finally beat it after a couple hours. For good measure, I beat it a couple more times.

Then I started thinking about writing a bot that will solve it for me. Apparently, 2048 AI is pretty popular. I decided to try creating a 2048 bot. Problem is, I have no idea if I can make a Java desktop app that can load http://gabrielecirulli.github.io/2048/ and pass keyboard input to it. (anyone?)

So I'm forced to create my own 2048 for the desktop. Oh well. It's a good learning experience for me since this will be my first puzzle game that relies on a 2d array.


I usually split these puzzle game solver bots into two categories: brute force and human strategy. I've made a Sudoku solver before using the strategy method. Unfortunately, I suck at Sudoku, therefore my bot sucks, since it's only as good as I am. Obviously, writing a brute force solver would finish the Sudoku puzzle easily, but where's the fun in that?

Most of what I've seen on 2048 AI uses the brute force method. Minimax, expectimax, etc. Basically, searching through possible scenarios for the best evaluation. I'm going to go the other method. I will impart my limited knowledge to my bot, and hopefully this thing will be able to solve it like I would.

UPDATE:
Ahhhahahaha . I can't stop working on my damn bot. Again, it doesn't use any brute force recursive searching. It's a decision bot, and it makes decisions that I would make. I've managed to get my bot to create the damn 2048 tile. Average score is ~6000. Highest score is ~28000. Wins 5% of the time.

My Bot Doing Work

 It still doesn't make the exact same choices I would make, since I haven't put all of my thought process into it yet, but it's enough to actually beat the game. My personal best is ~58000, close enough. Hell yeah

1 comment: