Pfeffel is like Wordle but it always lies to you.

The chances are high that you have already come across the word game Wordle.

If not: Wordle is an online version of the pre-computers game Bulls and Cows, with a couple of clever twists. Firstly, Wordle only lets you play once per day, with the same secret word being presented to all users. Secondly, on completing the game, Wordle provides a ‘share’ button, which allows you to copy and paste a grid representing your result that day on social media.

Wordle went massively viral in December 2021, and according to Wikipedia currently has more than 2 million daily players.

Since the rules of the game are very simple, it is also simple to implement, and there are already several variants:

  • Sweardle - A four-letter word, sweary variant
  • Absurdle - An adversarial variant which secretly changes the word as you play to make it harder
  • Letterle - A minimalist one-letter variant
  • Worble - A straight clone that lets you play multiple times per day

Like millions of other people, I have been playing Wordle every day for the last couple of weeks and tinkering with the idea of making my own version just for fun. But I didn’t want just to clone it. I wanted an idea.

Boris Johnson, the current Prime Minister of the UK (as of January 2022), is widely acknowledged to be one of the least honest politicians - against some fairly stiff competition - in the history of British politics. His middle name, or rather one of his middle names, is ‘de Pfeffel’.

So, last Tuesday evening, late, I began coding a variant of Wordle that always lies to you, and called it ‘Pfeffel’.

In the usual Wordle rules, there is a secret word you must guess. With each guess you get told which letters in your guess are not in the secret word at all, which letters are right but in the wrong place, and which letters are correct.

Pfeffel lies to you about this. If it tells you the letter is not in the word, this means that it is. If it tells you the letter is correct, then it may still be in the word, but not in that location. If it tells you the letter is right but in the wrong place, either it is not in the word at all, or it is actually correct.

This makes the game significantly harder than normal Wordle, though just about still playable. If you squint.

The code is not great - I wrote it in a tremendous hurry - but for what it’s worth, can be found here.

The bulk of the game logic can be found in the mark_guess function:

function mark_guess(candidate) {
  const cletters = candidate.split("");
  const wletters = word.split("");
  let mark;
  let correct = 0;
  for (let i = 0; i < word_length; i++) {
    if (wletters.includes(cletters[i])) {
      if (cletters[i] == wletters[i]) {
        // correct
        mark = pfeffel("guess-right");
        correct++;
      } else {
        // present but wrong place
        mark = pfeffel("guess-present");
      }
    } else {
        // wrong
        mark = pfeffel("guess-wrong");
    }
    const letterbox = document.getElementById(`guess-${cur_guess}-${i + 1}`);
    letterbox.classList.add(mark);
    if (mark == "guess-wrong") {
      const key = document.getElementById(`key-${cletters[i]}`);
      key.classList.add("key-wrong");
    }
  }
  if (correct == 5) {
    win_game();
  }
  if (cur_guess == max_guesses) {
    lose_game();
  }
}

This function takes a guess (candidate) and compares it letter by letter to the secret word (word). It then marks each letter in the guess with one of the three possibilities: guess-right, guess-wrong, and guess-present, the last of which is shorthand for ‘right-but-in-the-wrong-place’.

If you have guessed all five letters correctly you win; if you have run out of guesses you lose, otherwise the game continues.

However, before presenting the marks, the game runs them through another function called pfeffel:

function pfeffel(mark) {
  const options = ["guess-right", "guess-present", "guess-wrong"];
  const pfeffeled = options.filter(function(item) { return item !== mark });
  return pfeffeled[Math.floor(Math.random() * 2)];
}

This is the Boris Johnson function: whatever the truth is, it is guaranteed to return one of the two possible lies.

Other than that, the game is identical to Wordle.

I should probably go back and improve the layout code, which does not, but should use flexbox to ensure it works properly on all displays. I should add the rule that all guesses must be a real word (this will involve adding a huge List Of Real Words, but is fairly easy to do). I could look at adding some of the visual feedback that Wordle has (attempting to enter a non-word makes the guess wobble), and I absolutely ought to clean up the silly thing where I created a data structure for the whole game and then never use it, instead storing all gameplay directly in the page. Finally I could add a proper dialogue box at the end of the game rather than using the built in alert function.

There is a joke involving the ‘share’ button which you get if you complete the game - even if I added a share button, it would never actually share. People are getting enough Wordle-related spam and I don’t want to contribute to it.

But, for a one-off gag game that most people will have forgotten about in a few weeks, I’m not sure I can be bothered with any of that.

To my absolute delight, Pfeffel was featured in this week’s B3ta newsletter, which resulted in more hits to my website in the course of an evening than it has received since launch. Hits have now returned to their customary one or two per day, and my stats page is hilarious.

Which is as it should be, really.