Commit 2097c2bc authored by Jesse McGrew's avatar Jesse McGrew
Browse files

Implemented multi-commands and ordering.

Fixed bug where OOPS didn't work after orphaning.
[ZILF-13, ZILF-14, ZILF-73]
parent 625e40fd7c0d
......@@ -142,9 +142,7 @@ Args:
<SET INTERRUPT <CLOCKER>>
<SET T <+ .T 1>>
<COND (<OR <G? .T ,STANDARD-WAIT>
<AND .ENDACT>
<AND .INTERRUPT>>
.ENDACT
.INTERRUPT>
<SETG STANDARD-WAIT .BACKUP-WAIT>
;"To keep clocker from running again after the WAITED turns"
<SETG AGAINCALL T> ;"TODO: make sure this isn't causing an infinite loop"
<RETURN>)>>>
......@@ -82,7 +82,7 @@ Returns:
;"Confirm that the command looks like a noun phrase, and parse it into P-NP-XOBJ."
<COND (<OR <L? ,P-LEN 1>
<NOT <STARTS-NOUN-PHRASE? <GETWORD? 1>>>
<NOT <=? <PARSE-NOUN-PHRASE 1 ,P-NP-XOBJ> <+ ,P-LEN 1>>>>
<NOT <=? <PARSE-NOUN-PHRASE 1 ,P-NP-XOBJ T> <+ ,P-LEN 1>>>>
<TRACE 1 "[HANDLE-ORPHAN-RESPONSE: doesn't look like a noun phrase]" CR>
<RETURN ,O-RES-NOT-HANDLED>)>
......
This diff is collapsed.
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -50,8 +50,6 @@
(SYNONYM BUCKET)
(FLAGS CONTBIT OPENBIT TAKEBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
<MOVE ,WINNER ,STARTROOM>
<MOVE ,APPLE ,STARTROOM>
......
......@@ -2,7 +2,7 @@
<SETG NEW-VOC? T>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -29,8 +29,6 @@
(SOUTH TO HALLWAY)
(FLAGS LIGHTBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
;"In case a test leaves it in the wrong place..."
<MOVE ,WINNER ,STARTROOM>>
......@@ -52,7 +50,7 @@
<EXPECT "That sentence has no verb.|">
<CHECK <IN? ,WINNER ,STARTROOM>>
<COMMAND [APPLE \, NORTH]>
;"TODO: EXPECT once ordering is implemented"
<EXPECT "Talking to an apple, huh?|">
<CHECK <IN? ,WINNER ,STARTROOM>>>
<TEST-CASE ("Direction followed by garbage")
......
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -25,8 +25,6 @@
(SYNONYM DOOR)
(FLAGS DOORBIT OPENABLEBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
<MOVE ,WINNER ,STARTROOM>
<FCLEAR ,WOODEN-DOOR ,OPENBIT>
......
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -26,8 +26,6 @@
(SYNONYM TROLL)
(FLAGS PERSONBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
;"In case a test leaves it in the wrong place..."
<MOVE ,APPLE ,STARTROOM>
......
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -57,8 +57,6 @@
<NOW-DARK?>
<RTRUE>)>>
<INSERT-FILE "testing">
<TEST-SETUP ()
<MOVE ,WINNER ,STARTROOM>
<MOVE ,FIREFLY ,STARTROOM>
......
;"https://bitbucket.org/jmcgrew/zilf/issue/25/local-globals-doesnt-work"
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<ROOM PILL-ROOM
(DESC "Strange Room")
......@@ -30,8 +30,6 @@
(WEST TO PILL-ROOM)
(FLAGS ONBIT LIGHTBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
<MOVE ,WINNER ,PILL-ROOM>>
......
<VERSION ZIP>
<INSERT-FILE "parser">
<COMPILATION-FLAG DEBUG T>
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -62,8 +64,6 @@
(ADJECTIVE BLUE)
(FLAGS TAKEBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
<MOVE ,WINNER ,STARTROOM>
<MOVE ,APPLE ,STARTROOM>
......
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -12,8 +12,6 @@
(DESC "dial")
(SYNONYM DIAL)>
<INSERT-FILE "testing">
<SYNTAX TURN OBJECT TO OBJECT = V-TURN-TO>
<ROUTINE V-TURN-TO ()
......
<VERSION ZIP>
<INSERT-FILE "parser">
<COMPILATION-FLAG DEBUG T>
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -13,11 +15,34 @@
(SYNONYM APPLE)
(FLAGS VOWELBIT TAKEBIT)>
<INSERT-FILE "testing">
<OBJECT RED-CUBE
(IN STARTROOM)
(DESC "red cube")
(SYNONYM CUBE)
(ADJECTIVE RED)
(FLAGS TAKEBIT)>
<OBJECT GREEN-CUBE
(IN STARTROOM)
(DESC "green cube")
(SYNONYM CUBE)
(ADJECTIVE GREEN)
(FLAGS TAKEBIT)>
<OBJECT BLUE-CUBE
(IN STARTROOM)
(DESC "blue cube")
(SYNONYM CUBE)
(ADJECTIVE BLUE)
(FLAGS TAKEBIT)>
<TEST-SETUP ()
<SETG TRACE-LEVEL 0>
;"In case a test leaves it in the wrong place..."
<MOVE ,APPLE ,STARTROOM>
<MOVE ,RED-CUBE ,STARTROOM>
<MOVE ,GREEN-CUBE ,STARTROOM>
<MOVE ,BLUE-CUBE ,STARTROOM>
<MOVE ,WINNER ,STARTROOM>>
<TEST-CASE ("Correct an unrecognized word")
......@@ -29,6 +54,28 @@
<EXPECT "I don't know the word \"appppplllleeee\".|">
<COMMAND [DROP APPLE]>
<EXPECT "You drop the apple.|">>
<TEST-CASE ("OOPS while orphaning (ambiguous noun)")
<COMMAND [TAKE CUBE]>
<EXPECT "Which do you mean, the blue cube, the green cube, or the red cube?|">
<COMMAND ["GREN"]>
<EXPECT "I don't know the word \"gren\".|">
<COMMAND [OOPS GREEN]>
<EXPECT "You pick up the green cube.|">
<COMMAND [TAKE CUBE]>
<EXPECT "Which do you mean, the blue cube or the red cube?|">
;<CHECK <SETG TRACE-LEVEL 5>>
<COMMAND [THE "BLU"]>
<EXPECT "I don't know the word \"blu\".|">
<COMMAND [OOPS BLUE]>
<EXPECT "You pick up the blue cube.|">>
<TEST-CASE ("OOPS while orphaning (missing noun)")
<COMMAND [TAKE]>
<EXPECT "What do you want to take?|">
<COMMAND ["GREN" CUBE]>
<EXPECT "I don't know the word \"gren\".|">
<COMMAND [OOPS GREEN]>
<EXPECT "You pick up the green cube.|">>
<TEST-GO ,STARTROOM>
<VERSION ZIP>
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
(DESC "Start Room")
(NORTH TO HALLWAY)
(FLAGS LIGHTBIT)>
<OBJECT APPLE
(IN STARTROOM)
(DESC "apple")
(SYNONYM APPLE)
(FLAGS VOWELBIT TAKEBIT)>
<OBJECT ROBOT
(IN STARTROOM)
(DESC "robot")
(SYNONYM ROBOT)
(FLAGS PERSONBIT)
(ACTION ROBOT-F)>
<OBJECT RED-CUBE
(DESC "red cube")
(SYNONYM CUBE CUBES)
(ADJECTIVE RED RG RB)
(FLAGS TAKEBIT LOCKEDBIT)>
<OBJECT GREEN-CUBE
(DESC "green cube")
(SYNONYM CUBE CUBES)
(ADJECTIVE GREEN RG GB)
(FLAGS TAKEBIT)>
<OBJECT BLUE-CUBE
(DESC "blue cube")
(SYNONYM CUBE CUBES)
(ADJECTIVE BLUE RB GB NAVY)
(FLAGS TAKEBIT)>
<OBJECT HALLWAY
(IN ROOMS)
(DESC "Hallway")
(SOUTH TO STARTROOM)
(FLAGS LIGHTBIT)>
<ROUTINE ROBOT-F (ARG "AUX" PT)
<COND (<=? .ARG ,M-WINNER>
<COND (<AND <VERB? TAKE>
<FSET? ,PRSO ,TAKEBIT>>
<MOVE ,PRSO ,ROBOT>
<TELL CT ,ROBOT " picks up " T ,PRSO "." CR>)
(<AND <VERB? WALK>
,PRSO-DIR
<SET PT <GETPT <LOC ,ROBOT> ,PRSO>>
<=? <PTSIZE .PT> ,UEXIT>>
<TELL CT ,ROBOT " leaves." CR>
<MOVE ,ROBOT <GET/B .PT ,EXIT-RM>>)
(ELSE
<TELL "The robot doesn't respond." CR>)>)>>
<TEST-SETUP ()
;"In case a test leaves it in the wrong place..."
<MOVE ,APPLE ,STARTROOM>
<MOVE ,ROBOT ,STARTROOM>
<MOVE ,PLAYER ,STARTROOM>
<MOVE ,RED-CUBE ,STARTROOM>
<MOVE ,GREEN-CUBE ,STARTROOM>
<MOVE ,BLUE-CUBE ,STARTROOM>
<SETG WINNER ,PLAYER>>
<TEST-CASE ("ROBOT, TAKE APPLE")
<COMMAND [ROBOT \, TAKE APPLE]>
<EXPECT "The robot picks up the apple.|">
<CHECK <IN? ,APPLE ,ROBOT>>>
<TEST-CASE ("TELL ROBOT TO TAKE APPLE")
<COMMAND [TELL ROBOT TO TAKE APPLE]>
<EXPECT "The robot picks up the apple.|">
<CHECK <IN? ,APPLE ,ROBOT>>>
<TEST-CASE ("ROBOT, [GO] DIRECTION")
<COMMAND [ROBOT \, NORTH]>
<EXPECT "The robot leaves.|">
<CHECK <IN? ,ROBOT ,HALLWAY>>
<CHECK <IN? ,PLAYER ,STARTROOM>>
<COMMAND [NORTH]>
<EXPECT "Hallway||A robot is here.|">
<CHECK <=? ,WINNER ,PLAYER>>
<CHECK <IN? ,WINNER ,HALLWAY>>
<COMMAND [ROBOT \, GO SOUTH]>
<EXPECT "The robot leaves.|">
<CHECK <IN? ,ROBOT ,STARTROOM>>>
<TEST-CASE ("Ambiguous actor")
<COMMAND [CUBE \, LOOK]>
<EXPECT "Which do you mean, the blue cube, the green cube, or the red cube?|">
<COMMAND [RED]>
<EXPECT "Talking to a red cube, huh?|">>
<TEST-CASE ("Too many actors")
<COMMAND [RED CUBE AND GREEN CUBE \, LOOK]>
<EXPECT "You can only address one person at a time.|">>
<TEST-CASE ("Actor not present")
<REMOVE ,RED-CUBE>
<COMMAND [RED CUBE \, LOOK]>
<EXPECT "You don't see that here.|">>
<TEST-CASE ("Missing noun in order")
<COMMAND [ROBOT \, TAKE]>
<EXPECT "What do you want the robot to take?|">
<COMMAND [APPLE]>
<EXPECT "The robot picks up the apple.|">>
<TEST-CASE ("Ambiguous noun in order")
<COMMAND [ROBOT \, TAKE CUBE]>
<EXPECT "Which do you mean, the blue cube, the green cube, or the red cube?|">
<COMMAND [RED]>
<EXPECT "The robot picks up the red cube.|">>
<TEST-GO ,STARTROOM>
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -48,8 +48,6 @@
(SYNONYM BUGLE)
(FLAGS TAKEBIT EDIBLEBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
;"In case a test leaves it in the wrong place..."
<MOVE ,RED-CUBE ,STARTROOM>
......
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -18,8 +18,6 @@
<ROUTINE V-GENTLY-CARESS ()
<TELL "You gently caress " T ,PRSO "." CR>>
<INSERT-FILE "testing">
<TEST-SETUP ()
;"In case a test leaves it in the wrong place..."
<MOVE ,APPLE ,STARTROOM>>
......
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -33,8 +33,6 @@
(SYNONYM WALLET)
(FLAGS TAKEBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
;"In case a test leaves it in the wrong place..."
<MOVE ,WINNER ,STARTROOM>
......
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -40,8 +40,6 @@
(SOUTH TO STARTROOM)
(FLAGS LIGHTBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
;"In case a test leaves it in the wrong place..."
<MOVE ,PLAYER ,STARTROOM>>
......
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -44,8 +44,6 @@
(SYNONYM BUCKET)
(FLAGS CONTBIT OPENBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
<MOVE ,WINNER ,STARTROOM>
<MOVE ,APPLE ,STARTROOM>
......
<VERSION ZIP>
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
(DESC "Start Room")
(LDESC "Ldesc.")
(FLAGS LIGHTBIT)>
<OBJECT APPLE
(IN STARTROOM)
(DESC "apple")
(SYNONYM APPLE)
(FLAGS VOWELBIT TAKEBIT EDIBLEBIT)>
<OBJECT BANANA
(IN STARTROOM)
(DESC "banana")
(SYNONYM BANANA)
(FLAGS TAKEBIT EDIBLEBIT)>
<OBJECT HAT
(IN STARTROOM)
(DESC "hat")
(SYNONYM HAT)
(FLAGS TAKEBIT WEARBIT)>
<OBJECT CAGE
(IN STARTROOM)
(DESC "cage")
(SYNONYM CAGE)
(FLAGS CONTBIT TRANSBIT OPENABLEBIT)>
<OBJECT DESK
(IN STARTROOM)
(DESC "desk")
(SYNONYM DESK)
(FLAGS SURFACEBIT)>
<OBJECT BUCKET
(IN STARTROOM)
(DESC "bucket")
(SYNONYM BUCKET)
(FLAGS CONTBIT OPENBIT)>
<OBJECT RED-CUBE
(DESC "red cube")
(SYNONYM CUBE CUBES)
(ADJECTIVE RED)
(FLAGS TAKEBIT)>
<OBJECT GREEN-CUBE
(DESC "green cube")
(SYNONYM CUBE CUBES)
(ADJECTIVE GREEN)
(FLAGS TAKEBIT)>
<OBJECT BLUE-CUBE
(DESC "blue cube")
(SYNONYM CUBE CUBES)
(ADJECTIVE BLUE)
(FLAGS TAKEBIT)>
<TEST-SETUP ()
<MOVE ,WINNER ,STARTROOM>
<MOVE ,APPLE ,STARTROOM>
<MOVE ,BANANA ,STARTROOM>
<MOVE ,HAT ,STARTROOM>
<FCLEAR ,HAT ,WORNBIT>
<MOVE ,CAGE ,STARTROOM>
<MOVE ,DESK ,STARTROOM>
<MOVE ,BUCKET ,STARTROOM>
<REMOVE ,RED-CUBE>
<REMOVE ,GREEN-CUBE>
<REMOVE ,BLUE-CUBE>>
<TEST-CASE ("Multiple commands")
<COMMAND [PICK THE APPLE UP \. PICK UP BANANA THEN GET HAT \.]>
<EXPECT "You pick up the apple.|
|
You pick up the banana.|
|
You wear the hat.|">>
;"TODO: test cases to make sure multi-cmds are interrupted when a command 'fails',
including preaction conditions, HAVE check, pronouns no longer present"
<TEST-GO ,STARTROOM>
<VERSION ZIP>
<INSERT-FILE "parser">
<INSERT-FILE "testing">
<OBJECT STARTROOM
(IN ROOMS)
......@@ -24,8 +24,6 @@
(SYNONYM APPLE)
(FLAGS VOWELBIT TAKEBIT EDIBLEBIT)>
<INSERT-FILE "testing">
<TEST-SETUP ()
<MOVE ,WINNER ,STARTROOM>
<MOVE ,APPLE ,STARTROOM>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment