February 2018
Intermediate to advanced
304 pages
7h 11m
English
As you consider interactive play, you’ll need to make a few additions to the program. Right now the game only returns the final score, but an interactive game should report progress as the game progresses. Also, right now you’re choosing the word to guess, but we really need to let the program choose a random word so it’s a mystery to a human player.
Let’s tackle the random word first. Included in the hangman project is a file words.txt, which contains about 4000 words that you can use as a word bank. First, read those words into a data structure.
| | (defn valid-letter? [c] |
| | (<= (int \a) (int c) (int \z))) |
| | |
| | (defonce available-words |
| | (with-open [r (jio/reader "words.txt")] |
| | (->> (line-seq ... |