3.1 Description of the Camel Game

 

The idea for Camel originally came from the Heath Users Group and was published in More BASIC Computer Games in 1979.

The idea is to ride your camel across the desert while being chased. You need to manage your thirst, how tired the camel is, and how far ahead of the natives you are.

3.2 Sample Run of Camel

Here is a sample run of the game:

Welcome to Camel!
You have stolen a camel to make your way across the great Mobi desert.
The natives want their camel back and are chasing you down! Survive your
desert trek and outrun the natives.
 
A. Drink from your canteen.
B. Ahead moderate speed.
C. Ahead full speed.
D. Stop and rest.
E. Status check.
Q. Quit.
Your choice? C
 
You traveled 12 miles.
 
A. Drink from your canteen.
B. Ahead moderate speed.
C. Ahead full speed.
D. Stop and rest.
E. Status check.
Q. Quit.
Your choice? C
 
You traveled 17 miles.
 
A. Drink from your canteen.
B. Ahead moderate speed.
C. Ahead full speed.
D. Stop and rest.
E. Status check.
Q. Quit.
Your choice? e
 
Miles traveled:  29
Drinks in canteen:  3
The natives are 31 miles behind you.
 
A. Drink from your canteen.
B. Ahead moderate speed.
C. Ahead full speed.
D. Stop and rest.
E. Status check.
Q. Quit.
Your choice? b
 
You traveled 6 miles.
 
...and so on until...
 
A. Drink from your canteen.
B. Ahead moderate speed.
C. Ahead full speed.
D. Stop and rest.
E. Status check.
Q. Quit.
Your choice? C
 
You traveled 12 miles.
The natives are getting close!
 
A. Drink from your canteen.
B. Ahead moderate speed.
C. Ahead full speed.
D. Stop and rest.
E. Status check.
Q. Quit.
Your choice? C
 
You traveled 11 miles.
The natives are getting close!
You made it across the desert! You won!

3.3 Programming Guide

Here are the steps to complete this lab. Feel free to modify and add to the lab. Try the game with friends and family.

Create a new program and print the instructions to the screen. Do this with multiple print statements. Don't use one print statement and multiple \n characters to jam everything on one line.

Welcome to Camel! 
You have stolen a camel to make your way across the great Mobi desert.
The natives want their camel back and are chasing you down! Survive your
desert trek and out run the natives.

  1. Create a boolean variable called done and set to False.
  2. Create a while loop that will keep looping while done is False.
  3. Inside the loop, print out the following:

    A. Drink from your canteen.
    B. Ahead moderate speed.
    C. Ahead full speed.
    D. Stop for the night.
    E. Status check.
    Q. Quit.

  4. Ask the user for their choice. Make sure to add a space before the quote so the user input doesn't run into your text.
  5. If the user's choice is Q, then set done to True. By doing something like user_choice.upper() instead of just user_choice in your if statement you can make it case insensitive.
  6. Test and make sure that you can quit out of the game.
  7. Before your main program loop, create variables for miles traveled, thirst, camel tiredness. Set these to zero.
  8. Create a variable for the distance the natives have traveled and set it to -20. (Twenty miles back.)
  9. Create and set an initial number of drinks in the canteen.
  10. Add an elif in your main program loop and see if the user is asking for status. If so, print out something like this:

    Miles traveled: 0

    Drinks in canteen: 3

    The natives are 10 miles behind you.

  11. Add an elif in your main program loop and handle if the user wants to stop for the night. If the user does, reset the camel's tiredness to zero. Print that the camel is happy, and move the natives up a random amount from 7 to 14 or so.
  12. Add an elif in your main program loop and handle if the user wants to go ahead full speed. If the user does, go forward a random amount between 10 and 20 inclusive. Print how many miles the user traveled. Add 1 to thirst. Add a random 1 to 3 to camel tiredness. Move the natives up 7 to 14 miles.
  13. Add an elif in your main program loop and handle if the user wants to go ahead moderate speed. If the user does, go forward a random amount between 5 and 12 inclusive. Print how many miles the user traveled. Add 1 to thirst. Add a random 1 to camel tiredness. Move the natives up 7 to 14 miles.
  14. Add an elif in your main program loop and handle if the user wants to go ahead drink from the canteen. If the user does, make sure there are drinks in the canteen. If there are, subtract one drink and set the player's thirst to zero. Otherwise print an error.
  15. In the loop, print “You are thirsty” if the user's thirst is above 4.
  16. Print “You died of thirst” if the user's thirst is above 6. Set done to true.
  17. Print “Your camel is getting tired.” if the camel's tiredness is above 5.
  18. Print “Your camel is dead.” if the camel's tiredness is above 8.
  19. If the natives have caught up, print that they caught the player and end the game.
  20. Else if the natives are less than 15 miles behind, print “The natives are getting close!”
  21. If the user has traveled 200 miles across the desert, print that they won and end the game.
  22. Add a one-in-twenty chance of finding an oasis. Print that the user found it, refill the canteen, reset player thirst, and rest the camel.
  23. Play the game and tune the numbers so it is challenging but not impossible. Fix any bugs you find.

3.4 Hints

  • Remember that it is good idea to put blank lines between logical groupings of code in your program. For example, but a blank line after the instructions, and between each user command.
  • It is considered better style to use while not done: instead of while done == False:
  • To prevent bad message combinations, such as printing “You died of thirst.” and “You found an oasis!” on the same turn, use the and operator. Such as, if not done and thirst > 4: