Skip to content

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.

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
app
 
 
 
 
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

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.

Topics

Resources

License

Packages

No packages published