Course:CPSC312-2017-2048-Haskell

From UBC Wiki

Title

Authors: Andrea Park, Ruxin Chen, Rhys Bower

What is the problem?

We are going to create the game 2048 based on http://2048game.com/ in Haskell. The objective of the game is to move the numbered tiles across the board to double it's value. The player wins the game by reaching the 2048 tile.

We will use the console to display the game state in our initial version. The keyboard arrow keys will be used to control the movement of the tiles. The game should display "Game Over" when there are no more moves or "Winner" when tile 2048 is created.

What is the something extra?

We will use Gloss to render a graphical interface for our game.

What did we learn from doing this?

(This should be written after you have done the work.) What is the bottom-line? Is logic programming suitable for (part-of) the task? Make sure you include the evidence for your claims.

This was an insightful project where we got to work with Haskell to produce a game. The rendering was not too complicated after we got Gloss setup. The main function is very similar to the world programs from CPSC 110 which made it easy to get started with rendering. The merging of tiles was more complicated but with Haskell we were able to come up with a solution that was easy to reuse components.

When we came up with our data definitions we didn't know we can have field names and we used pattern matching throughout the whole project. Later we learned that it's possible to have parameterized data definitions, and some changes might have been easier to make compared to pattern matching, as you can introduce a new field to the existing data without breaking every function that consumes this data.

We found it a bit unclear what packages (and what functions of these packages) to import and we had some hard time setting up the development environment at first. Other than that, Haskell seems to be a powerful language as with a bit more code (compared to the Prolog project), we are able to have a game with user interface.

Project Code