Compsci 100, Spring 2012, Hangman How-to

You can browse the code we provide and you can snarf it using our Ambient/Eclipse plugin --- check out the instructions on how to download the ambient system and how to use it to check out a project.

The snarf url for this CompiSci 100 is http://www.cs.duke.edu/courses/spring12/fall11/snarf/.

Statistical Analysis

We wrote code to call HangmanLoader.getRandomWord 10,000 times for word-lengths of 4-10. The results of one run are below.

word length # words
4 2209
5 3792
6 4959
7 5412
8 5379
9 4947
10 4059

If run again, the numbers above will be similar, but different. You'll need to decide on a strategy and code to get estimates of the number of different words for each word-length from 4-20 (inclusive).

In your assignment writeup you'll explain your methodology and include data about your conclusions. You're welcome to create and use charts, tables, etc. Please submit a pdf for your analytical writeup.

You should include the code you wrote to create your statistical analysis and explain how you ran the code to get the data you use in your analysis.

Provided Code/Classes

You are provided with four classes.

  1. The class HangmanStats will be the class that you'll use/modify in part 1 -- the statistical/analytical part of the program. It has both a public static void main(String args[]) that executes the code in the class.

  2. The class HangmanFileLoader loads a textfile and has a method to select and return a random word Look in the sample code in HangmanStats and HangmanGame to see how to use the class. You shouldn't need to modify this code at all.

  3. The class HangmanExecuter has the public static void main(String args[]) function that is the starting point of the Hangman game you write. It creates a HangmanGame and invokes the play method. You can write the game without modifying HangmanExecuter--if you do modify it, please include an explanation in your README.

  4. The class HangmanGame is the game-playing code, you'll modify the play method and you may add new methods or state/instance variables to this class.

For Java Help

Expect to spend some time getting used to the Java language. You should read pages 8-35 of your textbook. We have written a handy-dandy cheat sheet that shows example java code and matches it to Python and Matlab. The Java API docs provide info on what sort of operations Strings or other objects support. Using google can also work.

Coding Guidelines

The sample output on the assignment writeup page should be generically followed in that the user should see a representation of the secret word with guesses filled in, the letters used so far, and so on.