IBM SC34-5764-01 Server User Manual


 
/* CATMOUSE EXEC */
/* The user says where the mouse is to go. But where */
/* will the cat jump? */
say "This is the mouse ----------> @"
say "These are the cat's paws ---> ( )"
say "This is the mousehole ------> O"
say "This is a wall -------------> |"
say
say "You are the mouse. You win if you reach",
"the mousehole. You cannot go past"
say "the cat. Wait for him to jump over you.",
"If you bump into him you're caught!"
say
say "The cat always jumps towards you, but he's not",
"very good at judging distances."
say "If either player hits the wall he misses a turn."
say
say "Enter a number between 0 and 2 to say how far to",
"the right you want to run."
say "Be careful, if you enter a number greater than 2 then",
"the mouse will freeze and the cat will move!"
say
/*------------------------------------------------------*/
/* Parameters that can be changed to make a different */
/* game */
/*------------------------------------------------------*/
len = 14 /* length of corridor */
hole = 14 /* position of hole */
spring = 5 /* maximum distance cat can jump */
mouse = 1 /* mouse starts on left */
cat = len /* cat starts on right */
/*------------------------------------------------------*/
/* Main program */
/*------------------------------------------------------*/
do forever
call display
/*---------------------------------------------------*/
/* Mouse's turn */
/*---------------------------------------------------*/
pull move
if datatype(move,whole) & move >= 0 & move <= 2
then select
when mouse + move > len then nop /* hits wall */
when cat > mouse,
& mouse + move >= cat /* hits cat */
/* continued ... */
Figure 45. CATMOUSE EXEC 1/2
Programming Style and Techniques
Chapter 10. Programming Style and Techniques 91