Skip to content

Number Guessing Game

Daniel Gamboa edited this page Feb 13, 2017 · 11 revisions

Overview

Be a psychic and guess what number the computer is thinking!

Extracts routine to a function to reuse code. Convey the practicality and advantages of reusing code, clarity of modularity. This is the guessing game where players must guess a randomly chosen number (1-100). They get 7 guesses to find the number. Players are asked to guess a number and then are told whether the number is higher or lower than the real number. Initially we don't tell them how many guesses it will take and we will ask them to guess.

New Concepts

  • Loops
  • Functions

Let's Get Started

Sample Output

Stretch Goals

##Game of Pig

  • Rules: Two players race to reach 100 points. Each turn, a player repeatedly rolls a die until either a 1 is rolled or the player holds and scores the sum of the rolls (i.e. the turn total). At any time during a player's turn, the player is faced with two decision:
    • roll - If the player rolls a
      • 1: the player scores nothing and it becomes the opponent's turn.
      • 2-6: the number is added to the player's turn total and the player's turn continues.
    • hold - The turn total is added to the player's score and it becomes the opponent's turn.

Clone this wiki locally