Let's Play A Game

BJ’s niece had a birthday this month. As a surprise treat he’s asked you to help build her some fun games to play on her computer.

The Challenge

For this challenge we’ll be building a couple different games to play on the computer. Most will be text based with little graphics but if that is your expertise feel free to add any effects you want.

Creating a Test Case

Like in past challenges we’ll be using our tests to drive our development. No matter the level you choose to work with write a test case before you start your code. Then write just enough code to pass the test. Once you have passing code refactor to pass other test cases.

Level 1 Guess The Number

Write an program that creates a random number within a specified range (e.g. 1 - 100). Have the player input a number guessing the generated number. If it is the same the player has won. If it is not have the player continue guessing until they find the correct number.

Add a bit of a challenge to the game by assigning a point value to the amount of guesses a player makes. Keep track of the points for each round.

A Step Further

Going a step further offer to let the player have a hint. Start with a simple hint such as if the number is higher or lower than the guess. You may even offer to give a reduced range that the number could be within.

To increase the game feel reduce points for each hint taken. If you have multiple hint options they could be assigned a point value.

Level 2 Hangman

Hangman is a fun game kids like to play to stump their friends by writing out a number of blanks ___ on a board along with a scaffold for hanging someone. The blanks ___ correspond with letters in a word the players are trying to guess. Players have to guess the correct letters that are associated with the word or the image of a hanging stick man gets drawn.







|—–|
|
|
|
-–

_ _ _ _

|—–|
|    O
|    \|/
|    / \
-–

_ _ _ _

Create a hangman game that tells the player how many characters need to be guessed and how many chances they have left. If possible you may include an illustration. Also show which letters go into which spots on the word to guess. Indicate the letters that have been used either correct guesses or incorrect ones. You may do this my listing out the wrong letters or by having a list of available letters.

A Step Further

Gamify it even more by offering a difficulty level that sets the number of missed letters allowed before the game is lost. (Easy = 10, Normal = 5, Hard = 3)

Level 3 20 Questions

Kids like to ask a lot of questions, especially to their “know-it-all” uncle. Someone was smart enough to turn this into a game called 20 Questions.

For this level create game that will allow the user to ask questions to determine the chosen object or word. After each question allow the player the chance to guess the object. If they get it write they win if not they are allowed to ask another question about it.

To add to the challenge each question they ask reduces the number of points they get when guessing and each wrong guess reduces it even more. When the player has run out of points they have lost the game.

A Step Further

Reverse the roles. Have the computer ask the player questions to guess an object. Maintain the same rules for the points and when the computer has lost. Have it learn new objects so that if it does get one wrong it will add that data to it’s existing knowledge base and if that object is used again will get it correct. Also have the computer take a guess at the object once a certain threshold of information is gathered.