This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

RcCookie
RcCookie presents ...

2024/8/18

Hangman-Bot

(Takes a while to load)

This is a bot for the game Hangman (sometimes "Galgenmänchen" in German). This is a game between 2 people: the first player chooses a secret word and tells the second player only the number of letters in the word. Now the second player has to guess one character after another to try and find the word of player 1, and player 1 fills in the gaps where the letters appear. If player 2 guesses a letter not in the word, player 1 notes the letter and adds a line to the "hangman". If the hangman is completed before player 2 guessed the correct word, player 1 wins, otherwise player 2.

This bot takes as input the length of the word and its language (English or German). Then, you can fill in the known letters, and in the first "letters not in the word" fill in letters asked, which were not in the word.
The program then calculates the optimal letter to guess next. You can then fill in where that letter appears in the word (or state that it doesn't appear at all), and the program suggests the next guess.

The program has a long list of words for the two languages. Obviously, it can't guess the word if it's not in the list, but usually, it is. That is also why loading takes so long, it has to download all the words (which are wrapped in a java file).

The algorithm used to determine the next word works by grouping all remaining words, for every letter, which have the letter in the same places. It then calculates the expected elimination rate, that is, the average percentage of words which have the letter in different places.
(This is usually (disappointingly) the same letter as the one occurring in the most remaining words)

On the linked website (rccookie.de/hangman) I also have a more performant version of this program.

142 views / 13 in the last 7 days

Tags: game hangman bot

Your browser does not support the canvas tag.
A new version of this scenario was uploaded on 2024-08-18 20:05:49 UTC

Want to leave a comment? You must first log in.

Who likes this?

No votes yet.