Course:CPSC312-2018-Checkers

From UBC Wiki

Project Link

Authors:

Myron, Reed, Robert

What is the problem?

We're bored and we want to play a game. We don't have one in Haskell yet. Therefore, we will be implementing the board game checkers.

Checkers is a game with simple rules, but it has enough strategy and possibilities that an AI has to be at least somewhat complex in order to play it well. We will see if Haskell is feasible for running this type of turn based game and for creating a basic AI that can play these games.

What is the something extra?

We will create a basic AI for users to play, with multiple settings of difficulty. We will also have a fully functional text based user interface for displaying the game board and relevant information.

What did we learn from doing this?

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

Native Haskell is surprisingly more than sufficient to generate a viable computer board game with a basic AI. Haskell's IO, while confusing at first, was easy enough to display a menu and game board while playing the game. We also looked into creating a graphical interface for our game, but the library and documentation were unclear and confusing. Perhaps Haskell isn't as well suited for graphical purposes.

One benefit of the functional aspect of Haskell is that abstraction is very natural. Once you write a function that behaves correctly, you never have to worry about changing it or thinking too much about its internals. Refactoring is also very easy, since functions can be moved around without worrying about breaking things in other places. This is different from other languages where you can get yourself stuck by relying on too many side effects, causing refactoring and reasoning about what the function does to be difficult.

Functional languages also seem to be useful for solving naturally recursive problems such as finding the best move for the current game state. We used a modified version of the minimax function from the lectures, with a maximum depth and a new way to calculate the score of a new state. It would definitely be possible to exploit more features of the functional aspect of Haskell to make our AI much faster and smarter.

Overall, Haskell code can be used to provide the following:

- data definitions, both detailed and simple

- gameplay logic and functionality

- user interaction with input & response

- some text based user interface display

- automated procedures for AI

with relative ease. Haskell was a good language for our project and would be useful for any similar projects in the future. However, working with packages can be difficult especially with the lack of resources online. You must have the right task for the tools of Haskell.

Links to code etc

https://github.com/MyronL/CPSC312-2018W-P1