Kandidatarbete at CTH by Jennifer Krogh, Mattias Mattsson, Emma Pettersson, Simon Sundqvist, Carl Wiede, and Mårten Åsberg.
Project description/proposal (in Swedish)
Group page (access restricted)
A library with the basis for modeling and playing boardgames. Comes with built-in functions for playing games through a web interface (requires WASM compilation).
We use cabal
for development.
The library is located in ./src
. During development
cabal repl <path/to/file>
can be useful to test new features of the library.
A example executable is located in ./executable
. Use cabal run boardgame
to
test it.
A test suite is located in ./tests
. Use cabal test
to run it.
The UI side of this project is targeting the web by compiling the Haskell code to WASM with Asterius.
The easies way to use Asterius is with their prebuilt Docker container, here is how you do it:
- Firstly you need to install Docker, just follow the instructions from Docker docs.
- Once Docker is up and running, run the Asterius container with the following
command
Where
docker run -it -v $(pwd):/workspace -w /workspace terrorjack/asterius
$(pwd)
is the absolute path to this directory. Docker will mount this directory to the "workspace", where you can use all the Asterius commands. - The first time you use the container you must "boot"
Asterius, it is also a good idea to update cabal. Do that with these
commands:
Together they take about 20 minutes, and then you ready.
ahc-boot && ahc-cabal new-update
Well up and running, you should use ahc-cabal
instead of cabal
to compile
the project, we've also have a flag for activating the WASM features.
Building the executable should look like this now:
ahc-cabal new-build exe:boardgame --flags="wasm"
But building targeting WASM doesn't actually get us anything useful. To
transform the output to .wasm
and .js
you can use ahc-dist
. Run the
following command:
ahc-dist --browser --bundle \
--input-exe path/to/boardgame \
--output-directory /absolute/path/to/existing/out-directory
The --input-exe
is the path to the output of building the project, it's
probably dist-newstyle/build/x86_64-linux/ghc-8.8.4/boardgame-0.1.0.0/x/boardgame/opt/build/boardgame/boardgame
from the root of the project.
In your output directory you'll now find boardgame.wasm
and boardgame.js
,
and an example HTML file boardgame.html
showing how to use them. Open
boardgame.html
in a web server (can't load WASM from a local file), open the
console in your web browser, and play around with the window.boardgame
object.
If you wish to have a UI to play around with, you can mode the boardgame.wasm
and boardgame.js
files over to the example of the boardgame.js
repo.