May 2, 2014
This is a basic two player game of hangman. Player 1 will enter a word or phrase. Player 2 will then try to guess the letters in the word or phrase until they can guess what it is. They will be able to get six incorrect guesses before they lose. Player 1 can only win if Player 2 loses all of their guesses and Player 2 can only win by guessing the word or phrase correctly.
The heart and soul of this program is based on string and list manipulation. All of the input is received through input boxes which are featured in the GUI library. These input boxes return strings. Whenever I needed to check a guessed letter, I would have to go through the string and compare each individual character to the guessed character. To do this, I converted the string to a list so I could pass the cdr of the list recursively back into the function until I reached the end of the list. To simplify the program, every letter or word that was entered by the user was converted to lowercase with the string-downcase function. This is a built in function and was necessary so different cased letters were not registered as different letters.
- Recursion: Everything required recursion. Guessing letters involved looping through lists of characters so that each character in the string was tested.
- List/String manipulation: String manipulation involved changing uppercase to lowercase. List Manipulation involved character checking and traversing through lists of characters using car and cdr.
- Global Variables/Modifying State: All of the variables in this program are global because each one needs to be accessed by almost every function. Each function will somehow modify one of these variables with set! which assigns a new value to the variable. For example, one of the strings in the program is called blanks and it represents the word in dashes. Every time a letter is guessed correctly, the blanks string is updated by changing the correct dash with the letter and this new string takes the place of the original.
- Functions as Procedures: There are many instances where a function or procedure is passed to another procedure, especially in guessing letters because these functions often had to call themselves or other functions to test the letter that was entered.
The three external technologies I used are simply three libraries. The first two libraries are "turtles" and "turtles-examples." These two libraries allowed me to use all of the turtle graphing functions. This was used in creating the title screen and the hangman drawing. The third library is the GUI library. This library allowed me to use message boxes and also allowed me to get user input through input boxes. This was extremely helpful in creating an executable because there isn't a read-eval-print-loop in racket executables.
There isn't really anything in this program that will change the world. It's simply a game of hangman. This program really shines in its code. I think the list and string manipulation coupled with the recursion and higher order procedures really shows what we learned in this class. Hangman seems so simple, but there are a lot of things that need to be considered when you want to make a functioning game. Making the game involved combining everything we have learned with a little independent research.
Technology Used Block Diagram
This program is all scheme code. There wasn't any outside data that was read in and there wasn't anything that was really produced as a result. Instead, I provided a diagram to show what libraries went into this program.
Overall, I would have to say that this was a great learning experience. I spent a lot of time doing independent research so that I could code the features that made the game more exciting. It was great to take everything we have learned and combine it into one program. It's not perfect, but this Hangman game makes me proud.