Skip to content

Collection of AI algorithms to solve/optimize 2048 games.

Notifications You must be signed in to change notification settings

NathanWine/2048-AI-Solvers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2048 AI Solvers

AI solvers for the puzzle game 2048.

Python to C++ ported code from codebase made by Daniel Wu, Nathaniel Wine, and Yang Yang.

Port done by Nathaniel Wine.

Some modifications/improvements are present with the goal of further improved performance/quality.

About

The original project (as well as this one) was created with the goal of implementing algorithms to achieve as high of a score as possible in the game 2048. Game.cpp contains the code for the game logic, Heuristics.cpp contains several heuristic metrics/functions to evaluate game state quality, and algorithm implementations are split between MonteCarlo.cpp, Minimax.cpp, and Expectimax.cpp.

If unfamiliar with the game rules, check out 2048.

Setup

First, navigate to the proper directory and run

make all

...and then follow usage. Note that this codebase was written and tested in a Linux environment. Other operating systems may need to follow additional steps / procedures in order to run the program.

Usage

AISolver < flag_1 > < flag_1_val > < flag_2 > < flag_2_val > ...

Flag list:

  • -a: Integer/String value; Algorithm to run. 0 = MonteCarlo, 1 = Minimax, 2 = Expectimax
  • -n: Integer value; # times to run the algorithm. Stats displayed at program completion
  • -r: Integer value; # runs MonteCarlo completes for each move. Higher=better but slower. Recommend 10-100
  • -d: Integer value; # depth level for Minimax / Expectimax
  • -p: Integer value; Print level. Higher=more display. 0 = minimal, 1 = medium, 2 = high, 3 = full

Ex:

AISolver -a minimax -n 1 -d 1 -p 3