Hangperson -- creating the politically correct game

HangmanThe Hangman game has been played with pencil and paper for years. Hangperson -- the program doesn't change the basic game at all, but it does allow you to play it with your computer instead of having to have a real person make up and score words for you to guess. If you like, you can easily modify the word lists and create your own version of this game.


Hangperson -- instructions for running the program

To run Hangperson on your computer, just select the option shown below. When the program starts, select the difficulty level from the menu. Then guess letters until you discover the secret word or until the robot is hanged and the game is over. You can also select the two-player option and type in a word or phrase for someone else to guess.

You can easily modify Hangperson yourself by changing the word lists. With any word processor or editor you can put in your own words or phrases, creating your own version of this software. Before you try modifying this program, it's a good idea to run it yourself and then check the flowchart to see how it works.


Run the Hangperson program.

After you've finished running the program, press the Esc key to stop and return to this page.


See how it runs -- the flowchart

FlowchartThe first menu offers four choices. Depending on your choice, the computer will either select a word from one of the three word lists on the disk or ask you to type in a secret word from the keyboard.

After you have made your first selection, you can turn the sound effects on or off with the second menu.

Once the game starts, the computer loops in a continuous pattern, getting letters from the keyboard and displaying the results. This loop continues until one of two conditions is met.

The final step in the program is not shown in this flowchart. After Hangperson has decided whether you are hanged or are a winner, the program plays an appropriate tune and asks if you would like to go again.


Hang anybody you want -- add your own words to the game

Three lists of words are used as data files by the Hangperson program. If you are running this program from the CD-ROM, then the data in these files cannot be changed. If, on other hand, you have installed this program on your hard disk, the data files are available and can be modified or edited. For example, teachers could change these files to include spelling words. Other possibilities including modifying the data in these lists to include words that may -- or may not -- be appropriate. If you have access to the data files, choice of what to do is yours. Here's how.

Creating a custom version of this program is easy because you can easily add to or change the list of words to be guessed in Hangperson. I use three separate lists that you can modify with an editor or a word processor.

When you run Hangperson and select your list from the menu (Easy, Not so easy, A short phrase), your list of words will replace the original one that I wrote for this program.


Inside look -- video art (sort of)

Several of my friends are video artists and are very serious about using computers to express and share their vision. For them, a program like this that uses ASCII characters to print a simple robot on the screen hardly qualifies as "art" at all. But you have to start somewhere, and the simple art I use in Hangperson is easy to do.

Hangman You can also experiment with your own graphics that respond to a program. In this case, the robot figure begins with a head. The rest of the figure appears as each wrong letter is guessed. I even manage to change expression as the robot nears the end.

If you find that drawing is more fun than writing, you can skip the software stuff and just use this program as it is to select your own series of drawings to illustrate your favorite -- or not so favorite -- person being hanged. I used a unisex robot and even changed the name from Hangman to Hangperson so that I would be Politically Correct and not offend anybody. But that doesn't stop you from offending and hanging anyone you wish.

If you want an artistic and programming challenge, you could replace the robot figure in this software with some real video art -- such as a gorgeous blonde in an evening dress who could turn over letters one at a time, clap her hands like a trained seal, and maybe even have her own TV program. You would have to add some Artificial Intelligence to the program to make your artificial person intelligent enough to do this, but it might be worth it.

More about the person who wrote this seminar


Programmer's Toolkit

Hangperson introduces several new elements that I use in many keyboard-based programs. With these tools you can easily create any menu, draw boxes and clear sections anywhere on the screen, read and use data files in your programs, and use global constants to modify colors and other common items.

Universal menu maker

This is a general approach for creating any menu that selects from one to nine items on a list. If any subroutine deserves to be called a "classic", this is it. I have used this menu design in dozens of commercial products, including my first consumer programs sold on audio tape in 1976, the original Typing Tutor I sold to Microsoft and IBM, and my Computer Learning Lab series for Radio Shack and several other manufacturers. Here are the important features I suggest for any keyboard-based menu:

FlowchartYou can easily modify this SUB to create any menu you like. The flowchart shows how the sub works in detail. This flowchart illustrates how Menu(M$) prints the menu and gets a key from the keyboard. Scroll back (up) to see how this SUB fits into the complete Hangperson program.

The dollar sign in M($) is used in BASIC to signal that M represents a letter, or a word, or the name of a key instead of a value. In this example, M$ is used to record the name of the key that is typed. We have to use key names such as "1", "A", "x", and so forth so that this menu program can respond when a person presses a number key, the Escape key, or the Alt-F4 combination that is used as an escape in Windows.

When this menu is on the screen, the program loops continuously, waiting for an input from the keyboard. If the key matches one of the menu selections, the program exits this sub with M$ equal to the name of the key that was pressed. If the user presses Esc or Alt-F4, the program exits this sub with M$ = "Esc". Pressing any other key causes a beep and "Select (1-4)" to flash on the screen. Here is the complete code for this sub as it is used in Hangperson:

Yes or No?

This menu is similar to the one above, but it is created specifically to get a yes or no response. If the user presses a "y" or "Y", the YesNo$ = "yes". Pressing an "n" or "N" sets YesNo$ to "no." It's a good idea to check for both regular and capital letters because the CAPS LOCK key could be pressed when the user makes a selection. As with the menu above, pressing Esc sets YesNo$ to "Esc" and pressing any other key sounds a beep and flashes the "Select (Y/N)" line on the screen.

Global CONST

Using global constants is an option that can simplify your programs if you use the same values in many different places. In Hangperson I use these constants to define the colors that I use. To change a color everywhere it appears, just change these statements at the beginning of the program. To see all the colors that are available, run the TOOLKIT1 program or run COLOR0.EXE or COLOR12.EXE and see a color chart.

Reading an external data base

This program gets a random word from a data file on the disk. This sub uses several steps to load a file and select a random word. It also checks to make sure the same word is not used more than once. The program instruction looks like this:

Depending on the menu selection, FileName$ would match the name of one of the three files where words are stored. TestWord$ is the word that the computer has selected at random from the file. For details on reading files from the disk, see the GetFile sub in the toolkit.

InputWord (Word$, MaxLength)

This sub prints a line of spaces to show how many characters may be typed. You can back up with Backspace, and exit with the Esc key or with Alt-F4. Pressing Enter sets Name$ in this example equal to the name that was typed. Notice how these instructions in Hangperson work together to tell the user what to do and also get the input from the keyboard. The LOCATE instruction tells the computer where to print the line of hyphens (- - - - ) that show the maximum length of the word or phrase. The word the user types in is stored in Word$.


Seminar homewww.qwerty.com