Jump to content
Macro Express Forums

Challenge: "Wordle" and Macro Express


Recommended Posts

During the past year, perhaps some of you have developed a need for a daily Wordle fix. I know I have!

 

The "official" version allows you to play once a day:

 

https://www.nytimes.com/games/wordle/index.html

 

However, there are unofficial versions that allow unlimited plays. For example:

 

https://www.wordleunlimited.com/

 

Here are the rules of Wordle:

 

Players have six attempts to guess a five-letter word. Wordle gives feedback after each guess. If a letter is correct, it shows as a green tile. If a letter is correct but in the wrong position, it shows as a yellow tile. If the letter is incorrect, it shows as a grey tile.

 

The challenge: Create a simplified version of Wordle using Macro Express.

 

There are many parts to Wordle, so don't even think about tackling them all. My version doesn't keep score, doesn't check whether the words I guess are real words, doesn't display a list of already-selected letters, etc. etc. etc. My list of tasks not yet attempted is long.

 

Nevertheless, my version is playable. Sort of. On a good day.

 

Feel free to post partial solutions, or solutions that are on the verge of almost working!

Link to comment
Share on other sites

Let me state unequivocally that Macro Express is a totally inappropriate tool for creating games! Nevertheless, as I tinkered with my simplified Wordle, I realized it was possible to get further than I imagined possible. My Wordle is clunky and sometimes fails in interesting ways. But mostly it works.

 

My Wordle is stripped-down compared to the original. For example, mine doesn't track scores or report statistics. Perhaps the most conspicuous difference is that my version does not display a list of letters a player has already tried.

 

The user interface of my game doesn't look anything like the original. In fact, my Wordle looks exactly like a Microsoft Word document — and that's because it runs inside a Word document. And for that reason, I refer to my version as "Word-le!"

 

Word acts as a "container" for the game. A player types a guess into a Word document, and then presses Enter. Pressing Enter triggers another macro that analyzes the guess and uses Word's highlighting tool to "paint" each letter. Perfect matches are painted green, partial matches are painted yellow, and non-matched letters are painted grey.

 

To colour a letter, the script begins by outputting Shift + Right Arrow. This hotkey selects one character to the right. Then, the script outputs key sequences to interact the "Text Highlight Color" palette on Word's ribbon. For example, the key sequence to activate the green highlighter is this:

 

Quote

 

F10    // Move focus to the ribbon  (OK to substitute "Alt")

H        // Activate the "Home" tab

I         // Activate "Text Highlight Color"

Home // Move focus to the top-left corner of the colour palette

Right  // Arrow right once to select the Green patch

Space // Choose Green

 

 

 

When I posted this challenge last week, Word-le was barely working. And it was greatly simplified. The macro did not verify whether guesses were actual words, and there was only one answer. The current version picks a random answer from a list of 2300 common words, and accepts any guess from a list of 13,000 common and uncommon words. For example, "aargh" is a legitimate guess, but is never an answer. I found the two lists on the web.

 

My first sort-of-working version consisted of about 50 lines of Macro Express code. Over the past week, I've refined the script. The current version consists of about 120 lines of code spread over two scripts.

 

If you want to try Word-le, upload and import the "Word-le.mex" file. It contains two scripts, "Wordle Launcher" and "Wordle Engine." Then…

 

1.    Open a new Word document.

2.    Press Ctrl + Alt + Z to start "Wordle Launcher." (Feel free to change the hotkey!)

3.    A splash screen appears. Press Enter to start the game.

4.    "Wordle Launcher" enables the "Wordle Engine" macro which temporarily changes the behaviour of the Enter key. While Word-le is running, Enter is the hotkey activation for the "Wordle Engine" macro.

5.    Type your first guess, and press Enter. "Wordle Engine" analyzes the word. Based on the analysis, the script "paints" letters green (exact match), yellow (inexact match), or grey (not a match).

6.    You have six tries to guess the answer. If you succeed, the game is over. "Wordle Engine" is disabled, and this restores the Enter key to normal.

7.    Ditto when you don't guess the answer within six tries.

8.    While playing Word-le, you can exit at any time by typing a question mark in the Word document and pressing Enter.

9.    To play again, press the Ctrl + Alt + Z hotkey.

 

Here's a video of Word-le in action:

 

https://www.youtube.com/watch?v=vKTReEjkKUw

Word-le.mex

Link to comment
Share on other sites

Excellent, well done, Alan! Nice video too.

 

I was doing Wordle, Byrdle, Quordle and Nerdle every day for two weeks, introduced to it by a son. But it was typically losing me an hour or more from my day, so have recently given up all but Nerdle. I avoid cryptic crosswords for the same reason 🙂

(Ditto your Challenges!)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...