Skip to content

DmitrySharabin/mavo-wordle

Repository files navigation

Mavordle

Clone of the famous Wordle game built with Mavo.

Notes for Mavo developers (and “future me” 😜)

Guesses

How to determine which letter corresponds to which guess (1st, 2nd, etc.)?

The incomplete quotient of a letter index (inside the collection of used letters) and 5 (the length of a guess) is the answer: floor($index / 5). E.g., a letter with $index = 13 belongs to the third guess (guesses are numbered starting from 0) since floor(13 / 5) = 2.

Coloring

  1. We begin coloring letters after the first guess is committed (from the second attempt), i.e., the corresponding letters belong to the previous guesses: row < attempt - 1, where row = floor($index / 5).

  2. If a letter matches the corresponding letter of the hidden word, it's marked as correct (and colored green): get(hiddenWordLetters, $index mod 5) = letter.

  3. A letter that is among letters of the hidden word is marked as elsewhere (and colored yellow) unless it's only one in the hidden word (i) and is already in the right spot in the corresponding guess (ii):

    1. count(filter(hiddenWordLetters, hiddenWordLetters != letter)) = 4
    2. letter in filter(hiddenWordLetters, hiddenWordLetters = thisRowLetters)
  4. In all other cases, a letter is marked as absent (and colored dark gray).

  5. 1 + 2 + 3 + 4:

if(row < attempt - 1, if(get(hiddenWordLetters, $index mod 5) = letter, correct, if(letter in hiddenWordLetters, if(letter in filter(hiddenWordLetters, hiddenWordLetters = thisRowLetters) and count(filter(hiddenWordLetters, hiddenWordLetters != letter)) = 4, absent, elsewhere), absent)))

Keyboard

The button

By hitting the Delete button, we expect to delete letters only from the current guess, not the previous ones:

deleteif(guessLength > 0, last(game.usedLetters))

Buttons with letters

We allow constructing guesses not more than 5 characters long:

if(guessLength < 5, add(group('letter': key), usedLetters) & add(key, guessLetters))

Coloring

  1. We begin coloring the keyboard after the first guess is committed: attempt > 1.

  2. To be colored, the key has to be among characters of any previous guess:

contains(join(guesses), key)
  1. If the key is among previously correctly guessed letters, it's marked as correct (and colored green). Else if the hidden word contains the key, the key is marked as elsewhere (and colored yellow). Otherwise, it's marked as absent (and colored dark gray):
if(key in correctLetters, correct, if(contains(hiddenWord, key), elsewhere, absent))
  1. 1 + 2 + 3:
if(attempt > 1, if(contains(join(guesses), key), if(key in correctLetters, correct, if(contains(hiddenWord, key), elsewhere, absent))))

When the game is over?

  1. The user wins the game if the guess (5 letters word) matches the hidden word:
guessLength = 5 and guess = hiddenWord
  1. The user loses the game if they have used their last (the 6th) attempt and the guess (valid 5 letters word) doesn't match the hidden word:
guessLength = 5 and attempt = 6 and guessValid and guess != hiddenWord

About

Clone of the famous Wordle game built with Mavo.

Topics

Resources

License

Stars

Watchers

Forks