Skip to content

lucaspellegrinelli/2048_ai

Repository files navigation

2048 Artificial Intelligence

This is my take on making an artificial intelligence for the game 2048 made by Gabriele Cirulli (you can play the game here).

There are two approaches to the problem in this project. The first one is in the ai.js which uses minimax and a heuristic function that is some random variables extracted from the game (like the biggest tile, how close it is to a specific configuration and others) weighted by values defined by a genetic algorithm. This approch was the first one I had (and probably the most effective). Its can usually get 4096, but I've seen it get 8192 and even 16384.

The other approach that can be found in ai_conv.js also uses minimax to choose its moves but instead of using that heuristic, I simulated something like a convolutional neural network, where I made several convolutions in the game board until I got only a 1x1 matrix, and its remaining value is the output of how good that board is. It isn't exactly a neural network since I still use a genetic algorithm to optimize the weights instead of backpropagation, but the ideia is almost there. This approach isn't as good as the other one right now (best I've seen is a 2048 with 22556 points), maybe with more training and some reworks in the network eventually it can get somewhere. By the way, I didn't want to use a proper neural network for this since this is just a fun project that I want to mess around with possibilities.

Releases

No releases published

Packages

No packages published