Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- MasterMind Game
- Author: Peter Casey
- Version: 0.01
- Play the MasterMind......
- """
- def welcome():
- """
- Welcome the user, describe this
- is a MasterMind game
- Input: nothing
- Return: nothing
- """
- print("Welcome to MasterMind")
- def create_puzzle():
- """
- Create a puzzle for the user to guess
- Input: nothing
- Return: the puzzle (four color pegs)
- """
- print("create a puzzle")
- def get_user_guess():
- """
- Ask the user for their guess for one turn
- Input: nothing
- Return the user guess (four colors in order)
- """
- print("get the users guess")
- def evaluate_user_guess(users_guess, puzzle):
- """
- Evalute the users guess against the puzzle
- Input: the users guess, the puzzle
- Return: the Black and White pegs based on evaluation
- """
- print("Evaluate user's guess")
- return "BW"
- def show_guess_results(results):
- """
- Show player the result of their guess (on screen)
- Input: evaluation of user guess
- Return: nothing
- """
- print("Your guess results are:", results)
- def show_rules():
- """
- Display basic game rules and game play
- """
- print("Guess four pins from red, green, blue, and purple")
- print("List them in the order you wish")
- print("Enter the pins with R, G, B, or P")
- print("An Example: GRPB <press enter>")
- def play_one_round():
- """
- Play one round with a single puzzle
- Unlimited guesses until correct
- """
- puzzle = create_puzzle()
- correct_answer = False
- while correct_answer == False: # not correct_answer
- users_guess = get_user_guess()
- results = evaluate_user_guess(users_guess, puzzle)
- show_guess_results(results)
- correct_answer = (results == "BBBB")
- def game_loop():
- """
- Do the welcome, ask if interested in game play
- if so, play game, ask to go again
- """
- welcome()
- show_rules()
- wants_to_play = input("Want to play? (y/n) ")
- while wants_to_play in ['y', 'Y', 'Yes', 'yes']:
- play_one_round()
- wants_to_play = input("Want to play again? (y/n) ")
- game_loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement