Play Wordle, the Puzzle Game Using PowerShell

Play Wordle, the Puzzle Game Using PowerShell

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.

Word List

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

2 thoughts on “Play Wordle, the Puzzle Game Using PowerShell

  1. I am not sure where this game is and is it that text set at the bottom where it explains sort of what to g
    Do. I just guess a word or do you give me clues

    1. To create a new game, once you have the module installed run New-WordleGame in PowerShell. The game will think of a 5 character word for you to guess in 6 tries. Green letter means the letter is in the word and you have it in the correct spot within the word. Yellow means the letter is in the word but you have it in the wrong spot. Gray means the letter is nowhere in the word. After 6 guesses if you haven’t guessed the word, it will tell you what the word was.

Leave a Reply to Brad Wyatt Cancel reply

Your email address will not be published.