Anita Woodford

CSE 210 | Programming with Classes

Week 5: Solo Checkpoint Requirements

Overview

Hide and Seek Waken, lords and ladies gay, On the mountain dawns the day; All the jolly chase is here With hawk and horse and hunting-spear; - Sir Walter Scott -

Rules

Hide and seek is played according to the following rules.

  1. The hider's location is a random number between 1 and 1000.
  2. The player, acting as the seeker, searches for the hider by guessing their location.
  3. If the seeker moves closer to the hider's location, they tell the seeker, "Getting warmer!"
  4. If the seeker moves farther away from the hider's location, they tell the seeker, "Getting colder!"
  5. If the guess is correct the hider tells the seeker, "You found me!". The game is over.

I'm going to find you!
            Enter a location [1-1000]: 500
            (^.^) Getting colder!
            
            I'm running around, but I'll find you...
            Enter a location [1-1000]: 750
            (>.<) Getting warmer!
            
            Shhh. I'm sneaking in now...
            Enter a location [1-1000]: 917
            (>.<) Getting warmer!
            
            Shhh. I'm sneaking in now...
            Enter a location [1-1000]: 918
            (;.;) You found me!
            > _

Requirements

Your program must also meet the following requirements.

  1. The program must use the Hide-and-seek template.
  2. The program must have a README file with assignment and author names.
  3. The program must have a Hider class in addition to what is already provided.
  4. The Hider class must have two attributes called location (a number) and distance (a list of numbers).
  5. The Hider class must have two methods called get_hint, and watch. Watch accepts one argument called location.
  6. The program interface must resemble the sample provided above.

Suggestions

Follow these instructions if you don't know where to start.

  1. Prepare a project folder on your computer using the provided template (either by cloning the repo directly, or forking it first and then cloning).
  2. Read all of the code and comments very carefully. Pay special attention to how the classes collaborate with each other.
  3. Open the hider file. Define a new class called Hider. Add a class comment and create the necessary method stubs.
  4. Starting with the constructor, complete each method by adding the appropriate code. The constructor declares and initializes instance attributes with their default values.

    The watch method keeps track of how far away the seeker is by calculating the difference between their locations. The distance is appended to the corresponding attribute for later use.

    The get_hint method returns a hint that depends on whether or not the seeker has moved closer or farther away. This is determined by inspecting the last two distances contained in the distance attribute.

    Refer to the Director class frequently to understand how the Hider object is being used. This will help you complete the code.

  5. Verify that your program works by running it and playing until the game ends. You may have to run it several times to make sure the game plays correctly under all conditions. Your output should be similar to the example provided.
  6. Please note that this is a different game than a binary search you where you might always guess in the middle of a range to see which side your target is on. Instead, the hints tell you if you're getting moving in the right direction.

Sample Solution

Compare your program to this version when you're finished. Ask yourself if you could make your program even better. You can also use this version to help you overcome any problems if you really need it. We all need help and inspiration from time to time. Don't make this decision too quickly though. It's in your best interest to complete as much as you can on your own.