About Projects Software Physics Tech Stump Me!



More Software Articles

No-limit Holdem Bot

Computer Plays Hangman

Paper Rock Scissors AI

The Omitted I in AI

Lisp











Computer plays Hangman


So I wrote a simple program that plays hangman, the simple game you may remember from elementary school. Someone selects a word, draws out the blanks for each letter and you guess letters until you figure out what the word is. Usually with each wrong guess a stick figure is drawn and if completed you lose. In this simple program you get strikes for each wrong guess. I allow 20 strikes which is a little high, but for comparison sake, I wanted it to be easy to look at the results and determine by how much better a human or the computer is at figuring out the word. At the end of each game the number of wrong guesses, and total guesses are displayed. My program has two modes, smart and dumb mode. Dumb mode is the simple algorithm. As the computer guesses letters it narrows down what word it could be based on words that still "match" based on the right letters. Smart mode uses several other methods to eliminate both words that don't fit and the letters still available to be guessed.

The limited testing I have done shows that as I expected the computer is way quicker at hangman than a person. Especially in smart mode, the computer can find words in far fewer guesses and strikes. Not really shocking, after all it is just simple string manipulation and matching strategies. Anyway, download it and test some friends. Type in the word into the program and give them the word on paper....see how many guesses and strikes your friend takes compared to the computer. Simple instructions, after downloading unzip the package and you should have a folder with a text file and an exe. Make sure the text file and exe are placed in the same directory somewhere on your computer. Run the exe and follow the instructions. Make sure that you enter the word in all lower case, and also proper nouns (names) wont work. Have fun!!!





Pat's Gaming Blog Rusty's Blog Contact
nter Code -->