Inspiration

Everyday, you can see applications of neural networks around us. As problems grow increasingly complex, humans are beginning to rely on neural networks to solve these problems. For instance problems such as computer text recognition, image classification, and decision making are all problems now delegated to neural networks. We wished to learn more about neural networks and how exactly they can be used and incorporated into our every day lives, so we built this program.

What it does

This program takes the fun and popular game 2048 and trains neural networks to get a high score. 2048 is a game that is easy to pick up, but difficult to master. As a result, we could not directly program in strategies to the neural network or make it follow our commands. As a result, we made a reinforcement learning neural network that gradually learns from it scores how to become better. To help allow the neural network to learn, we used a genetic algorithm, which uses real life biological mechanics such as crossing over, mutations, populations, and other aspects of genetics to evolve the best neural network.

How we built it

In the beginning, we had the idea of making a neural network in order to learn more about how they worked and how they could be applied to the real world. First off, we had to start by making a game of 2048. We couldn't use an external game because a) the animations would slow down the neural network and b) it gave us more control. Then, we made a randomly generated neural network that would take in inputs, feed them forward through hidden neurons, and then get outputs. After verifying everything was working, we put into place the genetic algorithm, which managed the learning of the network. The final thing we did was optimize our algorithm to produce the best possible program and make small refinements to our program, such as visualizing the network, restarting, etc.

We build the entire program using a language called Processing, which is built on type of Java. It makes it much easier to learn and to draw shapes to a canvas, which is incredibly useful in making a game of 2048.

Challenges we ran into

First of all, most of our group members had little experience with programming. Therefore, we had to get over this gap by spending a few hours getting those group members comfortable with Processing and the idea of a neural network. Besides this, we ran into many other technical challenges. For instance, we had many bugs where lines were mistyped and hours were spent searching for those bugs. However, the biggest problem we faced was the initial inefficiency of our network. The network would get into a position, and then continually try to move in one direction. However, if this move was impossible, the network would simply freeze and not do anything. This was an initial issue, as it obliterated scores as many networks simply stopped working. Therefore, we had to make various modifications to our network to solve this problem and allow it to choose its next best move when it got stuck. Another issue we faced was due to the inherent RNG of the game of 2048. Tiles randomly spawn, making it difficult to train networks effectively, since they may sometimes get lucky or unlucky. Therefore, to reduce this, we began running each network not once, but multiple times to hopefully minimize the effects of RNG. This had a posiive effect on the final result and led to our final product.

Accomplishments that we're proud of

Despite none of us ever building a reinforcement learning neural network before, and some of us not even hearing about a neural network before, we managed to build one that can play 2048 suitably well. Additionally, we managed to think of several optimizations and ways to possible improve the bot. Additionally, we are proud of our formatting and the overall asthetic of the program. We are also proud of how we managed to get seemingly 3 different functions into our program.

What we learned

We learned many things from this experience. First of all, most of our group learned about Processing and Neural Networks. All of us learned more about reinforcement learning networks and genetic algorithms to evolve neural networks.

What's next for Neural2048

We are excited to try and experiment with new problems that require neural networks to solve. This program hopefully demonstrates the power of neural networks, as well as how they work. We all certain learned a lot while working on this project, and we are excited to learn more about neural networks and other forms of machine learning in the future.

Share this project:

Updates