INCLUDE "standard.adl"; { Object properties specific to this scenario } BROKEN = 1; { The window can be broken } { Locations in this scenario } NOUN room1, room2; room1(LIGHT) = TRUE; room2(LIGHT) = TRUE; { The vocabulary for this scenario } ADJEC sun, red, blue; NOUN wall, floor, sun window(room2), door(room1), red ball(room1), blue ball(room1); PREP against; hard = red; wooden = red; soft = blue; foamy = blue; sunwindow = sun window; bounce = throw; { Location descriptions } room1(LDESC) = ($say "You are in your bedroom. All of your really FUN toys have been ") ($say "put away, out of your reach. There is another room to the east.\n") ; room1(SDESC) = ($say "Bedroom\n"); room2(LDESC) = ($say "You are in the nursery. A pretty yellow sunbeam is shining on the ") ($say "floor. There is another room to the west.\n") ; room2(SDESC) = ($say "Nursery\n"); { Transition routines } cg = ($say "You can't go that way.\n"); room1(ACTION) = ($miss cg cg 0 cg cg cg cg cg cg cg) ($hit .ME 0 0 room2 0 0 0 0 0 0 0) ; room2(ACTION) = ($miss cg cg cg 0 cg cg cg cg cg cg) ($hit .ME 0 0 0 room1 0 0 0 0 0 0) ; { Object specific routines } BallAct = { ACTION rout for balls } (IF ($eq @Verb throw) THEN (IF ($ne @Dobj %1) THEN { We're the iobj; don't perform an action } ($exit 0) ) (IF ($ne @Iobj wall) THEN ($say "You throw the ball at the floor, where it bounces a few ") ($say "times, then is still.\n") ELSE ($say "The ball sails through the air, then bounces off the wall ") ($say "onto the floor.\n") ) ($move @Dobj ($loc .ME)) ($exit 1) ) ; red ball(LDESC) = ($say "There is a hard, wooden red ball here.\n"); red ball(SDESC) = ($say "a red ball"); red ball(ACTION) = (BallAct [red ball]); blue ball(LDESC) = ($say "There is a soft, foamy blue ball here.\n"); blue ball(SDESC) = ($say "a blue ball"); blue ball(ACTION) = (BallAct [blue ball]); NoAct = { ACTION rout for wall and floor } (IF ($or ($ne @Verb throw) ($ne @Iobj %1)) THEN (Silly) ) ; wall(NOTAKE) = TRUE; wall(ACTION) = (NoAct wall); floor(NOTAKE) = TRUE; floor(ACTION) = (NoAct floor); sun window(NOTAKE) = TRUE; sun window(LDESC) = ($say "There is a large sun window here") (IF ($prop [sun window] BROKEN) THEN ($say ", shattered into a thousand pieces!\n") ELSE ($say ".\n") ) ; sun window(SDESC) = (IF ($prop [sun window] BROKEN) THEN ($say "a broken window") ELSE ($say "a sun window") ) ; sun window(ACTION) = (IF ($and ($eq @Verb throw) ($eq @Iobj [sun window])) THEN (IF ($eq @Dobj [red ball]) THEN ($say "The red ball sails through the window, shattering it!\n") ($move [red ball] .ALL) ($setp [sun window] BROKEN TRUE) ($exit 1) ELSEIF ($eq @Dobj [blue ball]) THEN (IF ($prop [sun window] BROKEN) THEN ($say "The blue ball sails through the broken window!\n") ($move [blue ball] .ALL) ELSE ($say "The blue ball bounces harmlessly off the window.\n") ($move [blue ball] room2) ) ($exit 1) ELSE (Silly) ) ELSEIF ($eq @Verb open) THEN ($say "You can't open a sun window!\n") ($exit 1) ELSEIF ($eq @Verb take) THEN (Silly) ) ; door(NOTAKE) = TRUE; door(LDESC) = ($say "There is a closed door here.\n"); door(SDESC) = ($say "a door"); door(ACTION) = (IF ($and ($eq @Verb throw) ($eq @Iobj door)) THEN ($say "The " ($name @Dobj) " bounces harmlessly off of the door.\n") ($exit 1) ELSEIF ($eq @Verb open) THEN ($say "The doorknob is too high for you to reach.\n") ($exit 1) ELSEIF ($eq @Verb take) THEN (Silly) ) ; { Scenario dependant routines } Parent = { The parent fuse } (IF ($eq ($loc .ME) room1) THEN ($say "Suddenly, the door to your bedroom opens! ") ELSE ($say "You hear the door in your bedroom opening! ") ) ($say "Your parents enter the room. ") (IF ($prop [sun window] BROKEN) THEN ($say "Daddy notices the broken window, and turns a funny red color. ") ($say "\"I see that you haven't learned your lesson, dear,\" says ") ($say "Mommy. \"I'm afraid that you will have to stay in here for ") ($say "at least another hour! ") ($say "Mommy and Daddy leave you alone again. Let's see what other ") ($say "fun things there are to do around here...\n") ELSE ($say "\"Have you learned your lesson, kiddo?\" asks Daddy. Seeing ") ($say "your cute little face seems to have charmed them! You're off ") ($say "the hook! Mommy and Daddy take you out to see \"The Care ") ($say "Bears Eat New York\", and you live happily ever after.\n") ) ($spec QUIT) ; VAR Rand[ 10 ]; (Rand + 0) = "You wonder if the blue ball will bounce off of the window.\n"; (Rand + 1) = "You wonder if the red ball will bounce off of the window.\n" ; (Rand + 2) = "You find a piece of lint on the floor, and eat it. Yum!\n" ; (Rand + 3) = "You can hear Kitty meowing outside.\n" ; (Rand + 4) = "You hear Mommy singing in the kitchen.\n" ; (Rand + 5) = "You practice making disgusting noises. THPPP! ZZZKKK!\n" ; (Rand + 6) = "You hear Daddy hit his head on the garage door.\n" ; (Rand + 7) = "You lick the wall, to see what it tastes like.\n" ; (Rand + 8) = "You pretend that you're an airplane. Zoom!\n" ; (Rand + 9) = "You make spider shadows with your hands.\n"; Random = { Random message daemon } LOCAL which; ($incturn) { Increment the turn counter } ($move wall ($loc .ME)) { Move the wall to my current location } ($move floor ($loc .ME)) { Move the floor to my current location } ($setg which ($rand 20)) (IF ($eq @which 1) THEN (IF ($ne ($loc [blue ball]) .ALL) THEN ($say ($global ($plus Rand 0))) ) ELSEIF ($eq @which 2) THEN (IF ($ne ($loc [red ball]) .ALL) THEN ($say ($global ($plus Rand 1))) ) ELSEIF ($le @which 10) THEN ($say ($global ($plus Rand ($minus @which 1)))) ) ; NOUN ME(room1); { The main actor in this play } (Indent) = TRUE; { Indent object descriptions } START = ($say "\n\n\n\n") { A few newlines for good measure } ($say "It all started so innocently! Kitty asked you for a haircut, ") ($say "so you took Daddy's neato electric razor, and gave her a Mohawk. ") ($say "Unfortunately, Mommy and Daddy didn't think it was so neat, and ") ($say "they stuck you in here for a fifteen minute time out period...\n\n") (StdInit ME) { Initialize standard } ($sdem Random) { Set up the random message daemon } ($sfus ME Parent 15) { Set up mommy and daddy } ($define "both" "red,blue") { Set up "both" to work } ($define "balls" "ball") { with the balls } ; { Dwimming routines } DWIMI = ($return (Dwimmer %1)); DWIMD = ($return (Dwimmer %1));