Course:CPSC312-2018-2048

From UBC Wiki

2048

Authors: Linda Cai, Adam Collins

What is the problem?

Here's a live version of the game. Use arrow keys to move the tiles. When two tiles of the same value touch, they merge into one with a doubled value. The goal is to reach 2048 and beyond until the board is full and no further merges can happen. That's when game is over.

https://gabrielecirulli.github.io/2048/

What is the something extra?

We will use gloss for a graphical user interface

http://hackage.haskell.org/package/gloss-1.13.0.1/docs/Graphics-Gloss.html

What did we learn from doing this?

We try to separate game logic, game render and game state in different modules to make the code easier to test and maintain

The external render package we use is powerful but has its limitations: it doesn't support font format too much

Some features common in other primitive programming languages need quite a bit of adjustment when it comes to Haskell due to its variable immutability. We tried to set user input settings from cmd as a global variable shared by many functions, and managed to do that with the help of some Monad. In the process, all the originally pure functions are "tainted" and transformed to IO functions. This maybe one of the trade-offs with Haskell in terms of code safety vs convenience.

Links to code etc

https://github.com/AdamCollins/CPSC312Project