Optimization of word lookup
It would be nice if the player of our Wordle game didn’t need to wait for the entire dictionary file to be read into memory given that it’s looking for only a few words. The dictionary file is sorted and each word is 5 letters long, so we should be able to check for the presence of a word using a binary search algorithm which has been modified to seek through the file.
Validation with HTTP requests
For word validation, a simple file lookup is a great start, but this file doesn’t contain support for valid words that are plural or past-tense. A variety of free API’s exist for simple word validation.Take a look at this one from Dictionary Api.Then use thehttp client hosted on Unison Shareto incorporate more robust guess validation.
Constructing a custom ability
Rewrite the game loop as a Console ability, the ability should be able to get user input, and write text out. A simple handler might interpret the Console ability into IO, and a more complicated console loop handler might conditionally run an interaction using the Console ability until a given predicate returns false.Check out the example ability handlers in the Stream tutorial online
Other command line games
The fundamental interactions for this command line game are shared with a variety of other games like Battleship, Connect4, etc. If you write one, post it!