Greedy, Yet Intelligent, Algorithms for the Game 2048 Using Python

CSEF · 2019 Mathematical Sciences

Overview

Objectives The objective of this project is to design, implement, test, and analyze simple algorithms to find the one that can achieve the highest tiles in the Google Chrome Extension of the game 2048. Methods Materials/environment: iMac desktop computer, Python v3.5, Pycharm IDE, free open source packages OpenCV and PyAutoGUI, Google Chrome extensions 2048 by Moloko and Empty New Tab Page by [email protected]. Tested twelve self-programmed algorithms (including two baseline algorithms) 200 games each, outputting collected data to .csv files. Used Seaborn, MatPlotLib, Pandas, and NumPy libraries to help me graph and analyze data. Results The optimal algorithms are a combination of chain reaction movement and the reward function given parameter 1 as the additional score (search depth 2 steps). Of those, the algorithm with the highest tile of the future board as parameter 2 appears to perform the best, and can reach the winning state of 2048 6.5% of the time. Conclusions I programmed and analyzed different algorithms for the game 2048. The optimal algorithm appears to be a combination of chain reaction movement and the reward function given parameter 1 as the additional score and parameter 2 as the highest tile of the future board. This demonstrates that a simple intelligent algorithm can achieve a good result comparable to that of more complex algorithms, given the right constraints and parameters to compare.

Summary statement

I devised a simple algorithm that can achieve the winning state of 2048.

Help received

After learning techniques from internet searches and online courses, I programmed and tested the algorithm by myself.

Competition history

  • CSEF 2019 Mathematical Sciences · Entry J1402

Resources

Related projects

Closest projects by meaning, across every fair and year in the corpus.

Browse more like this

Source: California Science & Engineering Fair public projects

Save projects to your library

Sign in with Google to keep track of projects you find interesting, organized into folders. An account also raises your daily allowance for “Has this been done?”, and lets you create a key for the MCP server with a much higher limit than anonymous use. Browsing stays public.

Continue with Google