Squeezing A Wordle Clone Onto The Game Boy

The popular word game Wordle is both an addictive brain teaser for some and a perpetual social media annoyance for others. Its runaway success has spawned a host of clones, among them one created for the Nintendo Game Boy with a reduced vocabulary. [Alexander Pruss] took on the challenge of improving it by fitting the entire 12972-strong 5-letter-word vocabulary as well as the 2315-word answer list into a 32K cartridge along with the code. The challenge in compression on a platform of such meager resources is to devise an algorithm which does not require more computing power or memory than the device has at its disposal. His solution is both elegant and easy to understand.

Starting by dividing the words into lists by first letter such that he can ignore the letter, he can reduce each word to 20 bits as four 5-bit letters. The clever part comes when he organises the words alphabetically, meaning that the 20-bit numbers representing each word are in numerical order.

Thus instead of storing the full number he could store the difference between it and its predecessor. With a few extra tweaks he was able to get the full list down to an impressive 20186 bytes, but was still faced with not enough space. Turning to the Wordle code he found that a library function call could be switched to an alternative with a much more efficient footprint, resulting in a new ROM with all words in place and ready to play.

Of course our community have applied their minds to Wordle and we’ve featured more than one hack based upon it. Mostly they have involved automated solving, so this retro gaming version breaks new ground.

Header image: Sammlung der Medien und Wissenschaft, CC BY 4.0.

9 thoughts on “Squeezing A Wordle Clone Onto The Game Boy

  1. /Users/marijnmuhlenbruch/Desktop/Screenshot 2022-03-01 at 15.44.01.png
    For the life of me I can not find the answer to this Game Boy wordle. A little help?

    1. Thanks for the link to my fork!

      In case it’s interesting here’s a link to the discussion where I worked with arpruss on shrinking the size and improving the speed of their implementation. It’s overflowing in commit notices, but if you expand it you can see the discussion. This is separate from the post on their blog where they are summarizing the results.

      https://github.com/arpruss/gb-fiver/pull/1

      In addition to shrinking size, we reduced lookup speed for slower answer word selection from about 1,601,000 (~22 CGB frames, very noticeable) cycles to about 58,500 (~.8 frames, imperceptible). I made extensive use of the profiler in the Emulicious Game Boy emulator to benchmark the code.

      BTW, there was another fork with a full dictionary implementation by zeta-two which was originally both smaller and (if I recall right) faster than the one by arpruss.

      https://github.com/ZetaTwo/gb-wordle

      Regarding the other person’s comment about SGB support: maybe… Depends how much free space is left in the ROM after other stuff on the list is completed.

      For convenience, here’s a link to the itch.io page for it. I just released a new version today with a bunch of improvements.

      https://bbbbbr.itch.io/gb-wordyl

      1. Just an updated reply to myself a while later. :)

        I needed some more space in the ROM so I worked on the compression using a couple suggestions from others (mostly on hackernews).

        The previous compressed dictionary size was: 17,757 bytes (encoded with 7-bit varints)

        After making changes to the compression the dictionary size came down to: 13,812 bytes

        To get it there required:
        – Changing to 3-bit varints
        – Reversing the word letters
        – Remapping the alphabet to a different order roughly based on frequency of use

        That also required improving the decode speed since each 3-bit varint was no longer guaranteed to be byte-aligned as the 7-bit ones were. Improving the speed added a little bit of extra bytes used.

        Switching to Base-26 could save a couple hundred more bytes, along with some other possible optimizations.

Leave a Reply to Marijn MuhlenbruchCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.