Table of Contents
I recently came across a NYTimes article talking about a new game called, ‘Wordle.’ If you are not familiar with the game, its a text-based game where you have 6 tries to guess the word. Letters in a Gray box are not letters found in the word. Letters in a Yellow box are found in the word, but are in the incorrect spot. And finally, letters in a Green box are in the word and in the correct location.
After playing, I decided to see how I could transport the game over to PowerShell because why not? After a few hours I got it working and uploaded to the PowerShell Gallery so everyone can play. Below, I will talk more in depth about some of the features, how to install the module, and how to create a new game.
Install the Module
The module is uploaded to the PowerShell Gallery, so to install it you just need to open a administrative PowerShell prompt and run Install-Module PSWordle
You can also install it manually, view, or contribute to the code by navigating to it on GitHub.
Start a New Game
Once you have the module installed, to begin a new game you just need to run New-WordleGame. From there, it will generate a random word for you to guess, prompt you for your input, and also explain the rules of the game. If you are not able to guess the word in the 6 tries it will display the word at the end. If you guess a letter that is not in the word, it will color the letter DarkGray and also keep a rolling record which will be displayed to you on each turn. If you guess a letter that is present in the word, but in the incorrect spot, it will color it Yellow. And finally, if you guess a correct letter and it is in the correct spot, it will color it Green. (More on the code behind the colorization of letters and words in a later article.)
Enable Emoji Responses
The function, ‘New-WordleGame’ contains one optional parameter, ‘-UseEmojiResponse’ which will respond back with either Yellow, Green, or Black colored square emojis instead of coloring the letters.
The word list contains hundreds and hundreds on entries. Using Invoke-RestMethod, the module grabs a random word from the following GitHub list: https://raw.githubusercontent.com/charlesreid1/five-letter-words/master/sgb-words.txt