Skip to content

lukxsx/2048-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2048-ai

codecov build

Data structures and algorithms project: Making an implementation of the 2048 game, as well as an AI bot to play it automatically using the minimax algorithm.

Links

Building

Prerequisites

You need a C compiler (GCC for example), Make and Check. (Some university's computer should have these already installed, at least on melkki).

Optionally if you want to generate HTML coverage report, gcovr must be installed. Otherwise you can use Codecov (link at the top of the page).

Arch Linux

pacman -S base-devel check

Debian/Ubuntu

apt install build-essential check

Compiling

Run the command

make

The program can be run with ./2048.

Tests

The unit tests can be run with

make check

Tests for the minimax algorithm can be run with

make mmaxtest

Code auto formatting

The code can be formatted with clang-format to ensure the constant code style. Note that clang and python must be installed to use this function.

make format

Coverage HTML report

Note that gcovr must be installed

make coverage-html

The generated file is called coverage.html.

Usage

Configuration

The program supports few command line options. If no options are given, the game will start in player mode (you control the game).

-a            Play with minimax AI
-d [value]    Set minimax depth (default is 5)
-s            Play with randomizer AI
-r            Play with randomized input
-t [value]    Delay in milliseconds
-c [runs]     Run in comparison mode
-h            Show this information

The ai.c file contains a few setting variables that can be changed before compiling. These affect the operation of the minimax algorithm.

Gameplay in player mode

The game can be played with W, A, S and D keys. Arrow keys are not currently supported.

About

A clone of 2048 game with minimax algorithm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages