Course:CPSC312-2017-Tetris

From UBC Wiki

Tetris

Authors: Tak P, Trevor L

What is the problem?

“State the general problem. If applicable, tell us what information you will use, e.g., a link to some web site that provides the information you used. What will you do?” We are endeavouring to implement a version of the classic game tetris: https://en.wikipedia.org/wiki/Tetris. This is a puzzle game where blocks of predefined shapes are ‘dropped’ from the top of the screen and moves down towards the bottom of the screen. Once a block cannot be dropped any further either by hitting the bottom of the screen or by dropping on top of another set of blocks, a new block is dropped from the top. When a row of blocks is formed with spans the entirety of the screen without any empty spaces, points are scored and the whole row of blocks is removed from the screen. The objective of the game is to clear the screen of all blocks.

What is the something extra?

“What is the in-depth aspect you will do? If the problem is related to some other group's project, tell us how they fit together. If in doubt, include the information.” The in-depth aspect we will do is to provide a coloured GUI and to make levels gradually more difficult as one progresses in the game. This means that pieces move faster down the screen as more screens are cleared.

What did we learn from doing this?

Logic programming was definitely suitable for the entire task of creating Tetris. We have managed to create a coloured GUI and to make the levels gradually more difficult for a functional game of Tetris. Other than merely visualizing the game, evidence of this is provided via game play, where pieces move towards the bottom of the screen faster as the game progresses.

Other things we learned about this is that the choice of data structures in Haskell makes a difference in how the function calls are structured and how logic is implemented. For example, we elected to use a Matrix as a representation of the tetris board in the game. This provided some advantages as it make accessing individual elements and columns easier, but made the setting of entire rows and elements somewhat more cumbersome. It also caused some issues with indexing, as the graphical portion of the program used 0-based indexing, while the matrix used 1-based indexing, causing some difficulties with integration and keeping track of which places need to be modified by ±1. We could have chosen a list representation instead of a matrix for the board, which addresses some of the concerns, but then would require more complicated logic to access all elements of a column.

Submission

Battleship can be found on [Github ].