Algorithm: Wheel of Fortune – Description and Design

1. Have the variable secretWord changed to secretPhrase and have a value assigned to it.
2. Prompt the user for a letter and display it in the right positions if it is in the secretPhrase. Otherwise, send a message to the player “incorrect” and keep track of how many times the player guesses the wrong letters.
3. Terminate the game after 5 tries. Display “game over” if it fails. Otherwise, displays “You are a winner!!” and add message with the prize(s)

Write YI_WheelOfFortune.py using what you learned from Hangman.py

1. Have the variable secretWord changed to secretPhrase and have a value assigned to it.
2. Prompt the user for a letter and display it in the right positions if it is in the secretPhrase. Otherwise, send a message to the player “incorrect” and keep track of how many times the player guesses the wrong letters.
3. Terminate the game after 5 tries. Display “game over” if it fails. Otherwise, displays “You are a winner!!” and add message with the prize(s)

Screen Shot 2014-11-16 at 5.52.28 PMScreen Shot 2014-11-16 at 5.53.09 PM

 

Designing the game:

  • Start by thinking to implement the secret phrase .
  • Make it similar to the secret word from the hangman.py program
  • The secret phrase has a phrase instead of a word. You have to think how you are going to handle the spaces. A suggestion from a student, Anna Schmult: replace a space with a “dash”. Shihan YU has a few good ideas about it. You can ask him also how he is handling this component.
  • Have a definition to randomly select a phrase
  • The definition should look very similar to getRandomWord(wordList) from hangaman.py
  • Write a short program to test your definition, and you handle the spaces and how you select randomly the phrase. Name this program YI_WheelOfFortune1.py
  • Next, work on the displayBoard() definition.
  • Don’t worry about the HANGMANPICS. You do not need it.
  • You can use the code for the missedLetters and the slicing to determine where the correct letter goes
  • Test your code works by writing a program YI_WheelOfFortune2.py. You can supply the list of phrases in the definition itself.
  • If you feel ambitious, you can add the code to the YI_WheelOfFortune1.py and return the secretPhrase as an argument to the displayBoard() definition.

 
 
THIS IS A GREAT PROJECT TO DISCUSS WITH YOUR CLASSMATES AND FROM OTHER PYTHON CLASSES!!! “DISCUSS” DOESN’T MEAN COPY THE CODE LINE BY LINE. IT MEANS UNDERSTAND THE STRATEGY AND APPLY IT TO YOUR OWN PROGRAM.