Depending on your existing experience with Unison, you can pick and choose how much direction you need about each of the following parts. In broad strokes, this is how we suggest tackling the problem.
We've provided some stub signatures and each section contains a link to more detailed instructions.
1. Install and set up the project
Once you have the UCM running, create a project for your Wordle clone.
scratch/main> project.create wordle
wordle/main>
The UCM will create the main
branch of your project for you and download the latest base
library into the lib
namespace. You can explore it with commands like ls
and view
or the UCM desktop.
2. Core logic and data modeling
- Implement Wordle’s core comparison logic and types: given a 5 letter user
Guess
, and a 5 letterTarget
word, return the guess with each character annotated with one of the three WordleResult
options
stubs.Guess.score : stubs.Guess -> stubs.Target -> [stubs.Result]
3. Rendering a guess to the console
- Colorize console feedback with The Terminus library from Unison Share
- Print out a rendered result to the console with IO
stubs.renderRow : [stubs.Result] -> Textstubs.renderGuesses : [[stubs.Result]] -> Text
4. Input validation and error handling
- Validate length of guesses
- Rerunning console interactions
stubs.getUserInput : '{IO, Exception, Ask (Set Text)} stubs.Guess
5. Game loop state and dictionary
- Query a provided file of 5 letter words for more validation options
- Write the loop which captures the user's guesses using IO and other abilities
- Run wordle, package it for sharing
stubs.gameLoop : Nat
-> stubs.Target
-> [[stubs.Result]]
->{IO, Exception, Ask (Set Text)} ()stubs.main : '{IO, Exception} ()
Wordle solver challenge task
- Write a wordle solver: see if it can outcompete your human friends
Additional challenges
That's it!
🖥 Give it a whirl! 🎉