Course:CPSC312-2023-4096

From UBC Wiki

4096

Authors: Yu, James

What is the problem?

Our specific goal is to implement a 2048 game in Haskell and document the challenges (and conveniences) that we encounter in order to inform others about how feasible making a 2048 game in Haskell is, compared to a widely known imperative language like Java. Because the components of 2048 are not uncommon (shapes, text, animation), we can generalize our findings to other basic games as well.

What is the something extra?

  • Since 2048 is the game that moving animation is important feature compared with other game such as Othello and card game, having fancy GUI attracts the users and improve user experience and we are going to work on this.
  • Also, we differentiated our project with others, for example, adding different board size (4*4, 5*5, 6*6). These are all elements to make our game more attractive for users.

What did we learn from doing this?

Functional programming, we used Haskell here, was somewhat suitable for our project.

We learned the patten matching was useful to implement a game. The game changes its state of player based on their actions and this will require us to behave differently according to the game state. The pattern matching made us easy to handle this.

Also, we found that putting types into classes by instance was really useful for GUI. Our package, called gloss, has a type of Picture and this will be used to draw on the window. We can easily define the our own data type Picture by putting them into the class that has a render function (return Picture type). After we defined how each data type is drawn via instantiation, we can just call a render taking the object that we want to draw on the window. The pattern matching was also quite used again to define render behavior because we can change the result of drawing based on the object’s properties.

Links to code etc

Course title
Image:wiki.png
Course title
Instructor:
Email:
Office:
Office Hours:
Class Schedule:
Important Course Pages

https://github.com/yunishimura0716/Haskell4096