Homework 3: Evil Hangman

02/12/2012: due date corrected

Your Mission

You've discovered that your old hangman game was a bit too easy and all of the kids at school are making fun of you for it. You come up with a brilliant but very secretive idea: you are going to modify your game into a new version that you've appropriately named Evil Hangman.

Your Timeline

This assignment is due on Friday, February 24 at 11:59pm.

You can work with one other person on this assignment. You only need to submit one solution.

Additional Details

Evil Hangman is played in exactly the same way as the original game; in fact, the player should have no idea that they're not playing the original game. The difference, however, is that the computer is actually cheating to make the game as hard as possible for the player: it doesn't actually settle on a word until the very end of the game, but tries to keep the player in the dark for as long as possible. Instead of picking a word at the very beginning a la regular hangman, it chooses a word but readily changes to a different word if the player starts guessing letters correctly. A flow chart describing one possible approach below is available here.

The dialog between the player and computer should look exactly the same as it did in your last assignment; in fact, it will probably be in your best interest to start from your project that you submitted as Homework 3. We have also provided a few word lists, but you're welcome to use your own for testing if you prefer. Remember to test your program on Word List 3 before convincing yourself that it completely works.

Note that you shouldn't worry about making your program work as efficiently as possible; you will not be graded on performance, only on correctness.

Gameplay Video

We've recorded a video of how our game looks when we run it. Remember that you are not being graded on how quickly your program runs -- there is a lot of extra work that has to go on behind the scenes so some slowdown is expected.

Starting Materials

You can either start with your submission for HW2, our solution to HW2, or a blank BYOB project.

Here are some example word lists that you can use for testing:

Tips and Thoughts

* To read a list from a text file: save the file in an easily-accessible location (such as your desktop). Open BYOB and create an empty list. Check the box beside your new list to have it appear in the display area. There will be a little handle on the bottom-right side of the list display -- right click (or Command + click on a Mac) the handle and you should see a dropdown menu, including an item that says "import." Select import, find your file, and open it. Each line of the text file will be imported as a new element in the list.

* Check out the flow chart. It describes one algorithm for getting the program working, although you're welcome to use others if they make more sense.

* You should be able to reuse a lot of code from your first homework. The main challenge for this project will likely be in designing your algorithms instead of writing tons of new blocks, so be sure to decide how you want your program to work before you start programming.

Extra for Experts

Try to make your Evil Hangman game as EVIL as possible. Try to come up with an algorithm that will make the player guess as many letters as possible before letting them win.

Try to make your Evil Hangman game run as quickly as possible. Designing effective algorithms will be your key tool in speeding up your program, and feel free to talk to your TA if you want to discuss your ideas.

* = a "letter pattern" is the positions that will be revealed in a word if a particular letter is guessed. For example, _ p p _ _ is one way to represent the letter pattern for "p" in the word "apple."

This assignment is based on the "Evil Hangman" activity written by Keith Schwarz. The original assignment is available on Nifty Assignments.