Introduction to Computer Science
CompSci 101 : Spring 2014

Hangman

Hangman is a traditional children's game, typically played with words. There are typically two people involved in playing the game: one that chooses the secret to be guessed by the other child and consistently updates the displayed state of the secret; and one that tries to guess what the secret is. For the purposes of this program, we will call the first child the Executioner (since this is hangman after all :) and the second child will be called the Player.

For this assignment you will program several aspects of a console-based, word-oriented game of hangman.

  1. Complete functions that check the rules of the game so that a winner and loser can be determined. You will be able to check your implementation by playing the game interactively between the Executioner and the Player.
  2. Complete simple strategies for the Executioner and the Player that make their choices based on simple randomness.
  3. Complete clever strategies for the Executioner and the Player that make their choices in "smart" ways by using information about the available possible words to choose the secret from.

To make the game easier to test, the possible words and the number of misses until the game is lost will be given to the game as parameters. That way you can choose from a small set of words to make sure you understand the choices being made or you can give the player as many chances as you want to guess the secret so you can make sure the game is winnable.

Details and guidelines of how to organize the program, including the methods you should write, are describd in the HOWTO page. Most of the code is already written for you, all you will need to do is complete the empty functions that are marked TODO in the code. To get started, download this code using Ambient's snarf tool.

Example runs of the game are available online and in the snarfable version. In the output files named _debug, we have included printed information that shows how the algorithm is "playing" the game, either as an Executioner or as a Player. The secret word and the number of possible words that could be the secret word are shown as well as any additional information about the data structures the algorithm is using.

Submission

There is no submission for this project --- questions about all three parts will be asked on the final exam.