Welcome to my command-line recreation of Countdown, the long-running Channel 4 game show.
In Countdown (the TV show), two players face off in a series Letters Rounds, Numbers Rounds and a final Conundrum. Whoever has more points at the end of the game is the winner.
- The game is functionally single-player.
- There is no time limit for any Round.
- Rounds can be played individually, outside the full game format.
Player picks 9 letters, including at least 3 vowels and 4 consonants, and makes the longest word they can. It must be at least four letters long to score. (The letter that appears is influenced by its frequency in English text.) Length of word = points scored. Double points for a 9-letter word! Zero for an invalid word.
Player selects 6 numbers from two lists, large (25, 50, 75, 100) and small (1-10, twice). A random three-digit target (between 101 and 999) is generated. Using the four arithmetic operations, the Player must get as close to the target as possible, with points earned based on proximity to the asnwer. An exact answer earns 10, ±5 or less earns 7 and ±10 or less earns 5. >10 away, a prohibited move or an incorrect final answer earns nothing.
Prohibited operations (with examples) include:
- Exponentiation (3^2 = 9)
- Non-integral division (5 / 2 = 2.5)
- Subtraction resulting in negative numbers (7 - 8 = -1)
A randomly-selected nine-letter word is shuffled. The Player must guess the original word. An anagram of the original word is permitted (e.g. 'cautioned', 'education', 'auctioned'). Success earns 10 points, otherwise the Player scores 0.
The following files have to be in the same folder to play this game:
- Countdown.py
- npn3.txt, the list of allowed words
- Letter weights.csv, assigning each letter of the alphabet its weight, according to its frequency of appearance in the English language. (See this Wikipedia article on letter frequency for more information. It's kind of interesting.)
Speeds up the testing/playing process:
- Letters Round: Automatically picks 4 vowels and 5 consonants.
- Numbers Round: Selects 2 large and 4 small numbers
Conundrum Round is disrespectfully slow. This is because a nine-letter, character-unique word produces 362880 different permutations. (I tried filtering out duplicates where this wasn't the case, but it was too slow.) Every permutation has to be checked against the imported word list to check if it's a valid word. The shuffled permutation itself cannot be a valid word. There may yet be probably some algorithmic inefficiencies that can be ironed out...
I ran this game using PyPy3, which makes use of just-in-time (JIT) compilation to speed up operation. It was definitely faster than Python 3.7.0, the standard implementation at the time I wrote this. However, the upcoming Python 3.11 is reportedly significantly faster than 3.10.
That's everything you need to know to play this game. Enjoy!