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/
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
// setup database
source docker/dependencies.env
docker-compose up -d
// with yesod
yesod devel
// or, using ghcid for subsecond code reload
make ghcid-yesod
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
stack test
stack bench
Original game by Gabriele Cirulli.
Heuristic based on Matt Overlan's.