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.
- Project specification
- User guide
- Test coverage report
- Implementation document
- Testing document
- Week 1 report
- Week 2 report
- Week 3 report
- Week 4 report
- Week 5 report
- Week 6 report
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).
pacman -S base-devel check
apt install build-essential check
Run the command
make
The program can be run with ./2048
.
The unit tests can be run with
make check
Tests for the minimax algorithm can be run with
make mmaxtest
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
Note that gcovr
must be installed
make coverage-html
The generated file is called coverage.html
.
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.
The game can be played with W, A, S and D
keys. Arrow keys are not currently supported.