1
!---------------------------------------------------------------------------
2
! NewbieGrammar.h, by Emily Short (emshort@mindspring.com)
4
! Being grammar statements and a couple of verbs to accomodate and
5
! respond to nonstandard kinds of input. It interprets who and what
6
! questions, as well as correcting some standard errors and redirecting
7
! other questions to Help.
9
! The current contents of this file are dictated by people's r*if posts about
10
! their frustrations with early attempts to play IF, and on the messages
11
! log on phpZork, which reveals what an assortment of random players
12
! have been known to attempt.
14
! Note that the general trend of these grammar lines are to catch things that
15
! are not what one might consider "legitimate" IF commands, or could not
16
! be translated easily into another IF action. There is a separate library,
17
! called ExpertGrammar, that provides some extra verb synonyms and equivalencies
18
! -- many of which were also suggested by analysis of newbie commands.
19
! The two libraries are separated because it is possible that one will want
20
! the ExpertGrammar without all the extra encumbrances of this library file.
22
! Version 0.6 -- still imperfect. If you have suggestions about
23
! more things the library should handle, please contact me to
26
! Thanks to Roger Firth for his corrections.
34
! This library file may be treated as public domain. It may be
35
! included with or without credit to the original author. It may be
36
! modified at the user's discretion. It may be freely redistributed.
40
! Parsing for the following forms:
42
! PLEASE... <anything> calls TooPolite, which tells the player such
43
! forms are not necessary
45
! I AM, YOU ARE, HE/SHE/IT IS... calls NewbieGrammar, which reminds
46
! the player to use imperative verbs.
48
! WHO AM I? calls MustXMe, which teaches the syntax for EXAMINE ME,
49
! then executes that command.
51
! WHO ARE YOU? calls ParserHelp, which explains the parser a bit.
53
! WHERE AM I? calls MustLook, which teaches LOOK, then executes that
56
! WHERE DO I FIND MORE GAMES LIKE THIS (and a wide range of variants)
57
! calls ArchiveIntro, which explains about the IF archive.
59
! WHERE CAN I GO NOW? (and variants) calls Exits, which is defined
60
! in this file just to tell the player to look around. If you
61
! would like to improve the functionality, you might want to look
62
! at one of the libraries that handles an EXITS command.
64
! WHAT DO I DO NEXT? (and a wide range of variants) calls
67
! WALK TO (and variants) calls LocalGo, which tells you
68
! that movement within a room is unnecessary.
70
! GO BACK (and variants) calls NoReturn, which tells you
71
! to be specific about which direction you want to return.
73
! CHECK FOR, LOOK FOR (and variants) calls SpecificSearch, which
74
! tells you to be specific about how to search for something
76
! Moreover, there is a catch-all, omnipresent item, which
77
! goes everywhere the player goes and reacts to
79
! -- attempts to use body parts to do things. This is to counteract
80
! newbie commands such as
81
! OPEN DOOR WITH FOOT, INFLATE RAFT WITH MOUTH, etc.
82
! -- vague instructions, such as KILL SOMEONE or TAKE SOMETHING
83
! -- vague locations such as HERE or ANYWHERE
85
! POSSIBLE DIRECTIONS:
87
! A couple of things one might also do if one really wanted to take this
90
! -- Use the UnknownVerb entrypoint to try to catch cases where the player is
91
! using a known noun to begin a sentence. Call NewbieGrammar in this case.
93
! -- Use ChooseObjects to make the allbodyparts item dispreferred in any
96
! -- Use BeforeParsing to look for certain standard adverbs, or else modify
97
! the "I only understood you as far as..." library message to remind the
98
! player that adverbs are not allowed. Many of the defective commands
99
! found in a study of newbie command structure included things such as
105
! -- Implement a fully functioning "GO BACK" verb that would return the
106
! player to his previous location. A. O. Muniz has already released
107
! a library to do this with Platypus; with the standard Inform library
108
! it is a bit more challenging, but not impossible.
113
! Include "NewbieGrammar" after Grammar in your gamefile.
115
! Note that if you are actually using who, what, or where verbs in your
116
! gave for legitimate purposes, you will need to change the grammar
119
! Set a ChooseObjects to make sure that allbodyparts doesn't show up
120
! on commands like GET ALL.
122
! It is also suggested that you Replace HelpSub before including this
123
! file. What is here is pretty minimal. If you wish to avoid compiling
124
! the grammar lines for 'help' (perhaps because you plan to use something
125
! else), define the constant NO_HELP_GRAMMAR before including this file.
127
!---------------------------------------------------------------------------
141
j = 0; w = NextWord();
142
if ((self.number == 0 or 1) &&
143
((w == 'my' or 'head' or 'hands' or 'hand' or 'ear' or 'ears') ||
144
(w == 'fist' or 'fists' or 'finger' or 'fingers' or 'thumb' or 'thumbs') ||
145
(w == 'arm' or 'arms' or 'leg' or 'legs' or 'foot' or 'feet') ||
146
(w == 'eye' or 'eyes' or 'face' or 'nose' or 'mouth' or 'teeth') ||
147
(w == 'tooth' or 'tongue' or 'lips' or 'lip')))
148
{ self.number = 1; j = 1;
150
if ((self.number == 0 or 2) &&
151
(w == 'someone' or 'something' or 'anyone' or 'anything'))
152
{ self.number = 2; j = 1;
154
if ((self.number == 0 or 3) &&
155
(w == 'here' or 'everywhere'))
156
{ self.number = 3; j = 1;
158
if (j~=0) i++; else return i;
165
if ((noun && noun == self) || (second && second == self))
167
self.message(self.number);
176
1: "Generally speaking, there is no need to refer to your body
177
parts individually in interactive fiction. WEAR SHOES ON FEET
178
will not necessarily be implemented, for instance; WEAR SHOES
179
is enough. And unless you get some hint to the contrary,
180
you probably cannot OPEN DOOR WITH FOOT or
181
PUT THE SAPPHIRE RING IN MY MOUTH.";
182
2: "The game will not arbitrarily guess what you want. Be specific --
183
use a noun for an object you can see around you.";
186
##Look, ##Search: <<look>>;
187
default: "You don't really need to refer to places in the game
195
if (NextWord()=='is' or 'am' or 'are' or 'was' or 'were')
196
return GPR_PREPOSITION;
200
if (NextWord()=='do' or 'does' or 'would' or 'will' or 'shall' or
201
'can' or 'could' or 'should' or 'may' or 'must')
202
return GPR_PREPOSITION;
207
if (NextWord()=='I//' or 'me' or 'he' or 'she' or 'it' or
208
'we' or 'you' or 'they' or 'person' or 'one' or
209
'someone' or 'somebody' or 'anyone' or 'anybody')
210
return GPR_PREPOSITION;
215
if (NextWord()=='more' or 'other' or 'another' or 'others')
216
return GPR_PREPOSITION;
220
[ SomeDirection w flag num;
227
{ return GPR_PREPOSITION;
231
if (w == 'left' or 'right' or 'straight' or 'ahead' or 'back'
232
or 'backwards' or 'forward' or 'backward' or 'forwards' or 'on'
233
or 'onward' or 'onwards' or 'around')
239
[ InternalNouns w flag num;
246
{ return GPR_PREPOSITION;
250
if (w == 'song' or 'music' or 'songs')
253
if (w == 'thought' or 'idea' or 'concept')
256
if (w == 'the' or 'a' or 'some' or 'any')
262
[ ThePoint w flag num;
269
{ return GPR_PREPOSITION;
273
if (w == 'point' or 'point?' or 'idea' or 'idea?' or 'goal'
274
or 'goal?' or 'purpose' or 'purpose?')
278
{ if (w == 'the' or 'a')
283
{ return GPR_PREPOSITION;
290
[ IsThisGame w flag num;
297
{ return GPR_PREPOSITION;
301
if (w == 'this' or 'these' or 'this?' or 'these?')
304
if (w == 'kind' or 'kinds' or 'of' or 'sort' or 'sorts' or 'like'
305
or 'such' or 'a' or 'as' or 'all' or 'is' or 'are')
308
if (w == 'game' or 'games' or 'story' or 'stories'
309
or 'game?' or 'games?' or 'story?' or 'stories?' or
310
'interactive' or 'fiction' or 'text' or 'adventure'
311
or 'adventures' or 'fiction?' or 'adventures?')
317
[ ThisGame w flag num;
324
{ return GPR_PREPOSITION;
328
if (w == 'this' or 'these' or 'this?' or 'these?')
331
if (w == 'kind' or 'kinds' or 'of' or 'sort' or 'sorts' or 'like'
332
or 'such' or 'a' or 'as' or 'all')
335
if (w == 'game' or 'games' or 'story' or 'stories'
336
or 'game?' or 'games?' or 'story?' or 'stories?' or
337
'interactive' or 'fiction' or 'text' or 'adventure'
338
or 'adventures' or 'fiction?' or 'adventures?')
344
if (NextWord()=='get' or 'find' or 'acquire')
345
return GPR_PREPOSITION;
349
if (NextWord()=='help' or 'assistance' or 'instructions'
350
or 'help?' or 'assistance?' or 'instructions?')
351
return GPR_PREPOSITION;
355
if (NextWord()=='supposed' or 'meant' or 'intended')
356
return GPR_PREPOSITION;
360
if (NextWord()=='now' or 'now?' or 'next' or 'next?'
361
or 'here' or 'here?')
362
return GPR_PREPOSITION;
366
if (NextWord()=='play' or 'play?' or 'use' or 'use?' or 'operate' or 'operate?'
367
or 'type' or 'type?' or 'do' or 'do?' or 'understand' or 'understand?'
368
or 'learn' or 'learn?' or 'work' or 'work?')
369
return GPR_PREPOSITION;
373
Verb meta 'hello' 'hi' 'howdy' 'greetings'
376
Verb meta 'you' 'he' 'she' 'it' 'they' 'we' 'its' 'theyre' 'were'
378
* topic -> NewbieGrammar;
380
Verb meta 'who' 'wh' 'whos'
381
* IsAmAre 'I'/'I?' -> MustXMe
382
* IsAmAre 'you'/'you?' -> ParserHelp
383
* IsAmAre noun -> Examine;
385
* IsAmAre 'I'/'I?'/'this'/'here'/'this?'/'here?' ->MustLook
386
* IsAmAre noun -> RightHere
387
* IsAmAre ThePoint ThisGame -> BoredHelp
388
* IsAmAre topic -> SpecificSearch
389
* DoCan Anybody 'go'/'go?' -> Exits
390
* DoCan Anybody 'go' NextThing -> Exits
391
* DoCan Anybody GetFind ThisGame ->
393
* DoCan Anybody GetFind More ThisGame ->
395
* DoCan Anybody 'look' 'for' ThisGame ->
397
* DoCan Anybody 'look' 'for' More ThisGame ->
399
* DoCan Anybody GetFind HelpName -> OutsideHelp
400
* DoCan Anybody GetFind HelpName 'with'/'for'/'on' ThisGame -> OutsideHelp ;
403
* IsAmAre ThePoint ThisGame -> Help;
406
* IsAmAre 'I'/'I?' -> MustXMe
407
* IsAmAre 'you'/'you?' -> ParserHelp
408
* IsAmAre 'here'/'here?' -> MustLook
409
* IsAmAre 'this'/'this?' -> Help
410
* IsAmAre Anybody Meant 'to' PlayUse -> Help
411
* IsAmAre Anybody Meant 'to' PlayUse
413
* IsAmAre Anybody Meant 'to' PlayUse
414
'in'/'on'/'for'/'with' ThisGame -> Help
415
* IsAmAre noun -> Examine
416
* IsAmAre ThePoint -> BoredHelp
417
* IsAmAre ThePoint ThisGame -> BoredHelp
418
* IsAmAre ThisGame 'about'/'about?'/'for?'/'for' -> BoredHelp
419
* IsAmAre ThisGame 'about'/'about?'/'for?'/'for' -> BoredHelp
420
* IsAmAre 'I' topic -> Help
421
* IsThisGame -> IntroHelp
422
* DoCan Anybody PlayUse -> VerbHelp
423
* DoCan Anybody PlayUse NextThing -> VerbHelp
424
* DoCan Anybody PlayUse
425
'in'/'on'/'for'/'with' ThisGame -> VerbHelp
426
* IsAmAre ThisGame -> IntroHelp;
430
* ThePoint ThisGame -> BoredHelp;
432
* DoCan Anybody PlayUse -> Help
433
* IsAmAre Anybody Meant 'to' PlayUse -> Help
434
* IsAmAre Anybody Meant 'to' PlayUse ThisGame -> Help
435
* DoCan Anybody PlayUse ThisGame -> Help
436
* DoCan Anybody GetFind ThisGame -> ArchiveIntro
437
* DoCan Anybody GetFind More ThisGame -> ArchiveIntro
438
* DoCan Anybody GetFind HelpName -> OutsideHelp
439
* DoCan Anybody GetFind HelpName 'with'/'for'/'on' ThisGame -> OutsideHelp
440
* DoCan ThisGame 'work'/'work?' -> OutsideHelp;
442
#ifndef NO_HELP_GRAMMAR; !!! added
443
Verb 'help' * -> Help
447
Verb 'please' 'kindly' * topic -> TooPolite;
451
* topic -> NewbieGrammar;
452
Extend 'walk' * SomeDirection -> NoReturn
453
* 'back' noun=ADirection -> Go
454
* 'around'/'about'/'away'
456
* 'on'/'over'/'across' noun -> Enter
457
* 'to'/'towards'/'around'/'past'/'under' noun
459
* 'over'/'up'/'down' 'to'/'towards' noun
461
Extend 'turn' * SomeDirection -> NoReturn;
462
Extend 'climb' * SomeDirection -> NoReturn
463
* 'back' noun=ADirection -> Go;
464
Verb 'keep' * 'going'/'walking'/'heading'/'running'
465
noun=ADirection -> NoReturn
466
* 'going'/'walking'/'heading'/'running'
467
noun=ADirection -> MustGo;
468
Verb 'continue' * noun=ADirection -> MustGo
469
* 'going'/'walking'/'heading'/'running'
470
noun=ADirection -> MustGo;
471
Verb 'return' 'back' * -> NoReturn
472
* 'to' topic -> NoReturn;
474
Extend 'check' * 'for' noun -> Examine
475
* 'for' topic -> SpecificSearch;
476
Extend 'look' * 'for' noun -> Examine
477
* 'for' topic -> SpecificSearch;
478
Extend 'search' * 'for' noun -> RightHere
479
* 'for' topic -> SpecificSearch;
480
Verb 'find' * noun -> RightHere
481
* topic -> SpecificSearch;
482
Extend 'wear' * noun 'on' noun -> Wear;
483
Extend 'sing' * InternalNouns -> InternalAccusative;
484
Extend 'think' * InternalNouns -> InternalAccusative;
487
"The parser does not understand polite formulations such as
488
PLEASE LOOK AROUND NOW or KINDLY OPEN THE BOX. Start your commands
489
with an imperative verb and they will work better.";
492
[ InternalAccusativeSub;
493
"In constructions like SING A SONG, the ~A SONG~ part is what is known
494
as an internal accusative -- a direct object that is not actually necessary.
495
In short: SING will do just as well. The game has difficulty with
496
parsing abstracts like ~a song~.";
500
print "[Generally, it is necessary to phrase commands like this as a simple
501
direction: GO NORTH, NORTH, etc., rather than KEEP GOING NORTH, HEAD BACK NORTH,
507
print "", (The) noun, " is ";
508
if (IndirectlyContains(player, noun)) "already in your possession!";
513
"If you want to look for something, try LOOK (to see
514
the room as a whole); LOOK IN containers; LOOK UNDER large items;
515
and SEARCH such items as piles and heaps.^^If you still can't
516
find whatever it is, you're probably out of luck...";
520
"The game does not keep track of your path through the rooms, nor
521
your orientation within them. Instead, you should rely on absolute
522
compass directions. If you
523
wish to visit a new location or return to a previous one, you will have to
524
type the directions to take you there -- NORTH, UP, etc.";
528
"The voice with which you are communicating is the narrator of the
529
game.^^[If you are having trouble with the game, try HELP.]";
532
"If the game is not understanding you, try issuing your commands in the imperative:
533
e.g., >THROW THE KNIFE, but not >I WOULD REALLY LIKE TO THROW THE KNIFE. Chatty sentences
534
such as >YOU ARE A VERY STUPID GAME will only prove themselves true.^^If you really
535
feel that the game is looking for a word that is not a verb (as the solution
536
to a riddle, eg.) try some variations, such as SAY FLOOBLE.";
539
print "[You can do this in the future by typing LOOK, which is quicker and
544
print "[You're the main character of the game. Of course, the game author may
545
have given you a description. You can see this description in the future
546
by typing EXAMINE ME, which is quicker and more standard.]^^";
550
Verb 'intro' * -> TotalIntro;
553
BasicBrief(); new_line;
555
#ifdef StartingInstructions;
556
StartingInstructions(); rtrue;
558
"This is a work of interactive fiction. You should explore and try to do things.";
561
#ifdef StartingInstructions;
562
StartingInstructions(); rtrue;
576
Verb 'verbs' * -> VerbHelp;
578
#ifdef StandardVerbs;
579
StandardVerbs(); rtrue;
585
Verb 'hint' 'hints' * -> HintHelp;
587
#ifdef StuckInstructions;
588
StuckInstructions(); rtrue;
598
"You can find more games like this at the Interactive Fiction archive,
599
http://www.ifarchive.org, and a guide to the archive at
600
http://www.wurb.com/if/.";
605
"Hi!^^If you are new to Interactive Fiction, you may want to type HELP.";
609
"If you LOOK, you may notice some compass directions you can use to
614
if (noun has door) <<enter noun>>;
615
"There's no need to walk towards items that are already
619
Verb 'demo' * -> Demo;
624
"No demo is available.";
629
"If you would like a list of verbs you could try, type VERBS.^^If the problem is more
630
that you don't know how to get going with the game, type INTRO.^^If you'd like a sample
631
of a game being played, type DEMO.^^Finally, if you know what you want to achieve
632
but can't figure out how to achieve it, type HINT.
633
^^If you are having further difficulty with IF, try looking at some of the online help sites
634
such as http://www.brasslantern.org.";
641
"This is a work of interactive fiction, in which you play the role of the
642
main character. You interact by typing text at the prompt.";