CSCI 150, Spring 2003

Home | | Course Schedule | | Assignments | | Lecture Notes

CSCI 150 Homework 3

The Game of High/Low

Due Friday, February 14, at the beginning of class.

Goals

The goals of this assignment include:

The Game of High/Low

The game of High/Low has two players. The computer program takes the part of one of the players, the quizmaster, and the person running the program takes the part of the other player, the guesser.

The quizmaster chooses a number, and the guesser attempts to guess it. After each guess, the quizmaster responds with one of three responses:

Your guess is high.
Your guess is low.
Your guess is correct.  You made 5 guesses altogether.
(Of course the number in the response, 5 in this example, varies, depending on the number of guesses the guesser actually made.) Here is a sample session.
C:\>highlow
I am thinking of a number between 0 and 20. 
Take a guess.
1
Your guess is low.
Take a guess.
13
Your guess is high.
Take a guess.
7
Your guess is low.
Take a guess.
11
Your guess is correct.  You made 4 guesses altogether.
Thanks for playing High/Low.
C:\>

Rules of the game

Quizmaster

The quizmaster chooses a number at the beginning of the game, and doesn't change it. All the numbers are integers. The various answers the quizmaster gives must all be correct, as must the announced range. The chosen number may be at either extreme of the announced range, for example number of 20 is legal for the range between 1 and 20. The quizmaster may change ranges for each game, but is not required to do so.

Guesser

The guesser should only answer with integer numbers; for example the answer 'one' is not a legal guess. The guesser's goal is to minimize the number of guesses, so although a strategy of counting through the range is perfectly legal, it is not the best plan. The guesser may repeat guesses, even though there is no point to doing so, or may guess numbers outside the range. The responses to such silly guesses are the same as for other high or low guesses.

Pascal features

You will turn in:

  1. A copy of the homework 3 cover sheet stapled to the front of the following items:
  2. A listing of your program. Be sure to properly indent and comment it.
  3. A printout of a run of your program.
  4. A diary of your adventures in writing and debugging your program. Include mention of the people you discussed it with, the times you started, continued, and finished. Particularly write about any snags or frustrations you encountered. (You'll probably need to take notes as you go in order to remember all this detail.)
  5. In addition, please email a copy of your program file, named <username>_choose.pas, as an attachment to me at croyden.mathcs.holycross.edu.