CPSC312-2023-Hangman2

From UBC Wiki
 Guidelines Create Your Wiki Page Past Projects Help and Resources 
Course title
Image:wiki.png
Course title
Instructor:
Email:
Office:
Office Hours:
Class Schedule:
Important Course Pages


Authors: Joel, Kenji

What is the problem?[edit | wikitext]

Our project will involve implementing the game Hangman as described here on wikipedia.

What is the something extra?[edit | wikitext]

We aim to provide the best user experience.

First, we will implement various levels of difficulty appropriate to the vocabulary of the player. One such variant would give the definition of the word which may help aid non-english speakers learn english.

Secondly, we want users to be able to keep track of all their past games and to be able to learn from them. We accomplish this by saving the game progress for every session by default, and giving the user an option to load the previously saved results in future sessions.

What did we learn from doing this?[edit | wikitext]

Haskell's strong typing and purity allow for safer and more robust code, and its functional nature provides a natural fit for the logic-heavy task of Hangman. In particular, Haskell's pattern matching and list manipulation features made it easy to implement Hangman's game mechanics, such as checking if a guessed letter is in the word, updating the game state based on the guess, and displaying the word with correctly guessed letters filled in.

Additionally, Haskell's type system helped catch errors early and ensure that the code worked as intended. For example, if a function expected a list of characters, it would not compile if given a list of integers, preventing runtime errors.

Furthermore, Haskell's strong emphasis on immutability and purity, while initially posing a challenge, ultimately resulted in clearer and more maintainable code. Since functions could not modify variables, their behavior was more predictable, and it was easier to reason about how changes to the game state would propagate through the code.

For the extra component, we had to utilize a file reading/write package as well as translating data types to JSON file and vise-versa using the Aeson library. It was instructional to learn about the various libraries and tools available in Haskell when researching potential implementation solutions.

Overall, the experience of programming Hangman in Haskell demonstrated the suitability of functional programming for logic-heavy tasks and the benefits of Haskell's strong typing, purity, and list manipulation features.

Links to code etc

https://github.com/klh1324/Hangman