6
$\begingroup$

Just as a diversion, I'd like to create an interactive Mathematica version of Wordle. As a sketch I have the following:

wordlist = 
Import["https://gist.githubusercontent.com/cfreshman/a03ef2cba789d8cf00c08f767e0fad7b/raw/a9e55d7e0c08100ce62133a1fa0d9c4f0f542f2c/wordle-answers-alphabetical.txt", "List"];
word = Characters[RandomSample[wordlist, 1][[1]]];
wordle[string_] := Module[{guess, thread},
guess = Characters[string]; thread = Thread[{word, guess}];
Row[Table[
 If[Length[DeleteDuplicates[thread[[t]]]] == 1, 
  Text[Style[DeleteDuplicates[thread[[t]]][[1]], Large, White, 
    Background -> Darker[Green]]], 
  If[MemberQ[word, guess[[t]]], 
   Text[Style[guess[[t]], Black, Large, Background -> Yellow]], 
   If[MemberQ[word, guess[[t]]] == False, 
    Text[Style[guess[[t]], White, Large, Background -> Gray]], 
    Text[Style[guess[[t]], White, Large, 
      Background -> Black]]]]], {t, 5}]
]];

(*wordle["stead"]*)

How can I make this sketch interactive?

$\endgroup$
3
  • $\begingroup$ Not a particularly helpful comment - but it might do to explain what Wordle is. I have never heard of it and I just asked my wife, stepdaughter and stepson and they have never heard of it either. $\endgroup$
    – 1729taxi
    Jan 16 at 14:07
  • $\begingroup$ Wordle is a popular word game in which you try to discover a 5-letter word by guessing other 5-letter words, with a mechanic somewhat similar to the schoolroom game hangman. $\endgroup$
    – Carl Lange
    Jan 16 at 14:21
  • 2
    $\begingroup$ A WL Wordle implementation on the Wolfram Community site. $\endgroup$ Jan 16 at 18:29

2 Answers 2

10
$\begingroup$

This is a very minimal interactive wireframe to get you started.

DynamicModule[{words = {}, word = ""},
 Column[{
   Dynamic@Column@words,
   Row[{
     InputField[Dynamic[word], String],
     Button["Submit", AppendTo[words, wordle[word]]; word = ""]
     }]}]]

Wordle

$\endgroup$
1
  • $\begingroup$ many thanks! :) $\endgroup$
    – martin
    Jan 16 at 14:56
6
$\begingroup$

Feel free to take a look at this on the Wolfram community that I did for fun:

a facsimile of Wordle

Moderators: update… I did not see that a link to this was added as a comment above. I am leaving this one as well, but feel free to change it to a comment or to delete it as you see fit. Thanks!

$\endgroup$
3
  • $\begingroup$ lots of fun to play with, thanks! :) $\endgroup$
    – martin
    Jan 17 at 2:00
  • 1
    $\begingroup$ Thanks! Enjoy! I recently added some additional explanatory text to the notebook. $\endgroup$ Jan 17 at 3:11
  • 1
    $\begingroup$ And here is a small blog post that I was asked to write: blog.wolfram.com/2022/02/04/wordle-the-wolfram-way $\endgroup$ Feb 4 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.