Course:CPSC312-2023-Wordle+
Authors: Andrew Huang, Keira Moore, Philly Tan
What is the problem?
The goal is to implement an implementation of the game "Wordle" in Haskell as a command-line version.
What is the something extra?
Unlike the original version of Wordle this allows players to request for "hints" towards solving the word. Examples of hints could consist of:
- How many vowels are in the word
- How many consonants are in the word
- How far off a letter is from the correct location
We're looking to create a heuristic to guide players as they guess their word. This heuristic takes into account the possibility of certain letters of showing up and guides them towards the best next words to guess.
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.
Our group took a functional and methodical approach to creating our Haskell Wordle with Hints by first implementing the game in Python -- a language we are more familiar with. We took a very functional approach in Python so that our Haskell adaptation would come together more smoothly (and surely enough, we were right). Both the Python and Haskell versions of our Wordle can be found in our github repository as linked below.
Approaching the Wordle game, we identified the states that must be kept (e.g. guess history, current word to guess), and created a play function (acts like the main function) that can be called. When play is called, our haskell program retrieves a random word from the Wordle word bank which we have stored in a .txt file. That word is then saved into the game, and passed along as a parameter for our other functions. From here on out, the function wordle is called with the wordToGuess parameter. Wordle then recursively calls itself, asking the user if they want to guess, ask for a hint, or see all previous guesses, until the game is solved.
One essential part of our project was the feedback function stringsMatch and stringsCompare which needed to alleviate the fact that our game was based out of command line rather than a typical user interface. We showed users their guesses attached with a symbol to indicate if the letter was in the correct spot, in an incorrect spot, or not in the word altogether. To complement this, we also added the colour code for the letters to match the original game (Yellow for partial, Green for correct, Gray for incorrect).
In addition to the original Wordle game, we implemented a system in which users can choose to receive hints in aid of them guessing the word.
Our main takeaways:
- Working with Haskell to parse text files to retrieve our words list
- Working with color coding words on command line outputs
- Designing a system and taking a methodical approach to creating our game
- Creating large scale haskell functions and working with (and debugging) types throughout the course of the project
All in all, we discovered that while haskell is able to create simple games like wordle, its implementation is much more obscure and complex than implementing the game in a language like Python. This is evidenced by the complexity / sheer amount of code that went into the two versions of the game, and the readability of the code, and finally just the amount of time it took to create each version (Python taking around 40 minutes, Wordle taking around 5 hours).
Links to code etc
https://github.com/phillytan/cpsc312-project-1