This is an algorithm to solve the popular hangman game.
Download the standalone app
How the algorithm works
- At first, the algorithm will compare the letter sequence it already guessed correctly (e. g.
_n_if the word is
nwas already guessed) to all words in the dictionary with the same length.
- The word with the greatest amount of common letters is called the 'priority word' as the player most probably wants the computer to guess this word.
- If at least 70% of the priority word are equal to the letter sequence, the algorithm will output the whole priority word as his next guess. Otherwise, it will proceed with step 4.
- Now, the algorithm counts the letters in all words in the dictionary with the same length as the letter sequence and produces a ranking of most used letters. (This step is completely independent from step 2)
- The ranking now gets filtered so that it only contains the characters that were not yet guessed and are contained in the priority word.
- The next guess is the letter at the highest position in the filtered ranking.
- Letters or words that have been proven to be wrong are temporarily removed from the dictionary.
How the heck can your algorithm play hangman in esperanto (and in 900 other languages)?
As the algorithms knowledge only depends on dictionaries, it is able to play hangman in almost any language that exists, including esperanto. Although we support 901 different languages, there are some languages that have better results than others. This mostly depends on the number of words in the corresponding dictionary. The more words the dictionary contains the better.
The social experiment
One evening when we were testing the algorithm, we had the idea to launch a social experiment using this algorithm. Here is the Plan:
- We will release a version of the algorithm for PC and Android
- Next, we will collect what words are the most used in hangman
- Which will give us a better dictionary
- And most importantly a good overview about what humans are thinking about most of the time.
Build the current snapshot
- Clone this repository
Build the latest release
Repeat the steps mentioned above but switch to the
release branch by running
git checkout release prior to runing
Contributions of any kind are very welcome. Just fork and submit a Pull Request and we will be happy to merge. Just keep in mind that we use Issue driven development.