An AI for the 2048 game using minimax and alpha-beta pruning, as described by John Hughes in the paper "Why Functional Programming Matters". The AI was written in Haskell and runs in a Yesod backend.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
benchmark
config
docker
eval
src
static
templates
test
.dir-locals.el
.ghci
.gitignore
LICENSE.txt
Makefile
NOTES.MD
README.md
package.yaml
stack-docker.yaml
stack.yaml

README.md

2048 AI

An AI for the 2048 game using minimax and alpha-beta pruning, as described by John Hughes in the paper "Why Functional Programming Matters".

The AI was written in Haskell and runs in a Yesod backend. The decisions are streamed to the browser via a websockets connection.

Demo: https://2048.diogocastro.com/

Run

Install stack, libsass, and, optionally, docker and docker-compose.

curl -sSL https://get.haskellstack.org/ | sh
brew install libsass

For development, you'll need either yesod or ghcid

stack install yesod-bin --install-ghc
stack install ghcid

Dev mode

// setup database
source docker/dependencies.env
docker-compose up -d

// with yesod
yesod devel

// or, using ghcid for subsecond code reload
make ghcid-yesod

Optimized

stack build --exec twenty48

To run in a docker container with HTTPS, you'll first need to generate a certificate for localhost, and then run:

make docker-build
source docker/nginx-localhost.env && docker-compose up -d

Tests and benchmarks

stack test
stack bench

Credits

Original game by Gabriele Cirulli.

Heuristic based on Matt Overlan's.