%mathpiper,title=""

roomsList := {};



//Kitchen.
kitchen := {};
kitchen["name"] := "kitchen";
kitchen["description"] :=
"
You are in a bright white room which has a sink on its
east wall which has cupboards above and below it. A table
with 4 chairs is in the center of the room and a refridgerator is
in its north west corner. Sitting on the table is 
a piece of paper with writing on it.

There is an exit to the north.

";

roomsList["kitchen"] := kitchen;


//Dining room.
diningRoom := {};
diningRoom["name"] := "dining room";
diningRoom["description"] := 
"
You are in a large rectangular room with a high ceiling.
There is an oak table in the center of the room with 12 
chairs around it.  There is a crystal chandelier above
the table. 

There is an exit to the south.

";

roomsList["dining room"] := diningRoom;




//Connect the rooms together.
kitchen["n"] := "dining room";
diningRoom["s"] := "kitchen";



%/mathpiper

    %output,preserve="false"
      Result: True
.   %/output


%mathpiper


currentRoom := diningRoom;

While( True )
[
    
    userInput := AskUser(currentRoom["description"] : Nl(): "Which direction (n,s,e,w,ne,se,sw,nw,q to quit)?");
    
    
    If(userInput = "q", Break());

    
    If(currentRoom[userInput] != Empty, currentRoom := roomsList[currentRoom[userInput]], TellUser("There is no exit in that direction."));
    
];

%/mathpiper

    %output,preserve="false"
      Result: True
.   %/output







%mathpiper,title=""

ForEach(direction, {"n","s","e","w","ne","se","sw","nw"})
[

 Echo(kitchen[direction]);
];

%/mathpiper

    %output,preserve="false"
      Result: True
      
      Side Effects:
      dining room
      Empty 
      Empty 
      Empty 
      Empty 
      Empty 
      Empty 
      Empty
.   %/output


