/
Questions IT.i7x
518 lines (389 loc) · 16.9 KB
/
Questions IT.i7x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
Version 4 of Questions IT by Leonardo Boselli begins here.
"Basato su Version 4 of Questions by Michael Callaghan."
"An extension to allow us to suspend normal parser input to receive and respond to answers to questions."
Chapter 1 - Global provisions for asking questions
Section 1 - Variables for asking questions
Current question is text that varies.
Current prompt is text that varies.
Saved prompt is text that varies.
Current question menu is a list of text that varies.
Current answer is indexed text that varies.
Section 2 - Default command line prompts for asking questions
Closed number prompt is text that varies. Closed number prompt is "Inserisci un numero >".
Open number prompt is text that varies. Open number prompt is ">".
Closed menu prompt is text that varies. Closed menu prompt is "Inserisci un numero tra 1 e [number of entries in current question menu] >".
Open menu prompt is text that varies. Open menu prompt is ">".
Closed yes/no prompt is text that varies. Closed yes/no prompt is "Inserisci S o N (Sì o No) >".
Open yes/no prompt is text that varies. Open yes/no prompt is ">".
Closed gender prompt is text that varies. Closed gender prompt is "Inserisci M, F o N (Maschio, Femmina e Neutro) >".
Open gender prompt is text that varies. Open gender prompt is ">".
Closed text prompt is text that varies. Closed text prompt is "Inserisci la tua risposta >".
Open text prompt is text that varies. Open text prompt is ">".
Section 3 - Flag to determine if the question is open or closed
Closed question mode is a truth state that varies.
Section 4 - Phrase used to ask questions in closed mode
To ask a closed question, in number mode, in menu mode, in yes/no mode, in gender mode or in text mode:
now closed question mode is true;
now saved prompt is the command prompt;
if in number mode:
if current prompt is "":
now the command prompt is the closed number prompt;
otherwise:
now the command prompt is the current prompt;
now number question mode is true;
if in menu mode:
if current prompt is "":
now the command prompt is the closed menu prompt;
otherwise:
now the command prompt is the current prompt;
now menu question mode is true;
if in yes/no mode:
if current prompt is "":
now the command prompt is the closed yes/no prompt;
otherwise:
now the command prompt is the current prompt;
now yes/no question mode is true;
if in gender mode:
if current prompt is "":
now the command prompt is the closed gender prompt;
otherwise:
now the command prompt is the current prompt;
now gender question mode is true;
if in text mode:
if current prompt is "":
now the command prompt is the closed text prompt;
otherwise:
now the command prompt is the current prompt;
now text question mode is true;
if current question is not "":
say "[current question][line break]";
if in menu mode:
repeat with counter running from 1 to the number of entries in the current question menu:
say "[counter] - [entry counter of the current question menu][line break]".
Section 5 - Phrase used to ask questions in open mode
To ask an open question, in number mode, in menu mode, in yes/no mode, in gender mode or in text mode:
now closed question mode is false;
now saved prompt is the command prompt;
if in number mode:
if current prompt is "":
now the command prompt is the open number prompt;
otherwise:
now the command prompt is the current prompt;
now number question mode is true;
if in menu mode:
if current prompt is "":
now the command prompt is the open menu prompt;
otherwise:
now the command prompt is the current prompt;
now menu question mode is true;
if in yes/no mode:
if current prompt is "":
now the command prompt is the open yes/no prompt;
otherwise:
now the command prompt is the current prompt;
now yes/no question mode is true;
if in gender mode:
if current prompt is "":
now the command prompt is the open gender prompt;
otherwise:
now the command prompt is the current prompt;
now gender question mode is true;
if in text mode:
if current prompt is "":
now the command prompt is the open text prompt;
otherwise:
now the command prompt is the current prompt;
now text question mode is true;
if current question is not "":
say "[current question][line break]";
if in menu mode:
repeat with counter running from 1 to the number of entries in the current question menu:
say "[counter] - [entry counter of the current question menu][line break]".
Chapter 2 - Questions that require a number answer
Section 1 - Flag to set number question mode
Number question mode is a truth state that varies.
Section 2 - Action for number questions
Number questioning is an action applying to one number.
Understand "[number]" as number questioning when number question mode is true.
Understand "dici [number]" as number questioning when number question mode is true.
Section 3 - Rules for number questions
Number question rules is a rulebook.
The number question rules have outcomes exit (success), retry (failure) and parse (failure).
The first number question rule (this is the invalid number reply rule):
if the player's command does not match "[number]":
if closed question mode is true:
retry;
if closed question mode is false:
parse.
The last number question rule (this is the default number question rule):
exit.
Section 4 - Processing number questions
After reading a command when number question mode is true:
follow the number question rules;
if the outcome of the rulebook is the exit outcome:
deactivate number question mode;
follow the every turn rules;
follow the advance time rule;
reject the player's command;
if the outcome of the rulebook is the retry outcome:
reject the player's command;
if the outcome of the rulebook is the parse outcome:
deactivate number question mode.
Section 5 - To deactivate number question mode
To deactivate number question mode:
now the Command Prompt is the saved prompt;
now the Current Prompt is "";
now number question mode is false.
Chapter 3 - Questions that require an answer from a menu
Section 1 - Flag to set menu question mode
Menu question mode is a truth state that varies.
Section 2 - Action for menu questions
Menu questioning is an action applying to one number.
Understand "[number]" as menu questioning when menu question mode is true.
Understand "dici [number]" as menu questioning when menu question mode is true.
Section 3 - Rules for menu questions
Menu question rules is a rulebook.
The menu question rules have outcomes exit (success), retry (failure) and parse (failure).
The first menu question rule (this is the invalid menu reply rule):
if the player's command does not match "[number]":
if closed question mode is true:
retry;
if closed question mode is false:
parse;
if the number understood is less than 1:
retry;
if the number understood is greater than the number of entries in the current question menu:
retry.
The last menu question rule (this is the default menu question rule):
exit.
Section 4 - Processing menu questions
After reading a command when menu question mode is true:
follow the menu question rules;
if the outcome of the rulebook is the exit outcome:
deactivate menu question mode;
follow the every turn rules;
follow the advance time rule;
reject the player's command;
if the outcome of the rulebook is the retry outcome:
reject the player's command;
if the outcome of the rulebook is the parse outcome:
deactivate menu question mode.
Section 5 - To deactivate menu question mode
To deactivate menu question mode:
now the Command Prompt is the saved prompt;
now the Current Prompt is "";
now menu question mode is false.
Chapter 4 - Questions that require a yes/no answer
Section 1 - Flag to set yes/no question mode
Yes/no question mode is a truth state that varies.
Section 2 - Value for use with yes/no questions
Decision is a kind of value. The decisions are Yes and No.
Understand "S" as Yes when yes/no question mode is true.
Understand "N" as No when yes/no question mode is true.
Section 3 - Action for yes/no questions
Yes/no questioning is an action applying to one decision.
Understand "[decision]" as yes/no questioning when yes/no question mode is true.
Understand "dici [decision]" as yes/no questioning when yes/no question mode is true.
Section 4 - Rules for yes/no questions
Yes/no question rules is a rulebook.
The yes/no question rules have outcomes exit (success), retry (failure) and parse (failure).
The first yes/no question rule (this is the invalid yes/no reply rule):
if the player's command does not match "[decision]":
if closed question mode is true:
retry;
if closed question mode is false:
parse.
The last yes/no question rule (this is the default yes/no question rule):
exit.
Section 5 - Processing yes/no questions
After reading a command when yes/no question mode is true:
follow the yes/no question rules;
if the outcome of the rulebook is the exit outcome:
deactivate yes-no question mode;
follow the every turn rules;
follow the advance time rule;
reject the player's command;
if the outcome of the rulebook is the retry outcome:
reject the player's command;
if the outcome of the rulebook is the parse outcome:
deactivate yes-no question mode.
Section 6 - To deactivate yes/no question mode
To deactivate yes-no question mode:
now the Command Prompt is the saved prompt;
now yes/no question mode is false.
Chapter 5 - Questions that require a gender answer
Section 1 - Flag to set gender question mode
Gender question mode is a truth state that varies.
Section 2 - Value for use with gender questions
Gender is a kind of value. The genders are Masculine, Feminine and Neutral.
Understand "M" as Masculine when gender question mode is true.
Understand "F" as Feminine when gender question mode is true.
Understand "N" as Neutral when gender question mode is true.
Section 3 - Action for gender questions
Gender questioning is an action applying to one gender.
Understand "[gender]" as gender questioning when gender question mode is true.
Understand "dici [gender]" as gender questioning when gender question mode is true.
Section 4 - Rules for gender questions
Gender question rules is a rulebook.
The gender question rules have outcomes exit (success), retry (failure) and parse (failure).
The first gender question rule (this is the invalid gender reply rule):
if the player's command does not match "[gender]":
if closed question mode is true:
retry;
if closed question mode is false:
parse.
The last gender question rule (this is the default gender question rule):
exit.
Section 5 - Processing gender questions
After reading a command when gender question mode is true:
follow the gender question rules;
if the outcome of the rulebook is the exit outcome:
deactivate gender question mode;
follow the every turn rules;
follow the advance time rule;
reject the player's command;
if the outcome of the rulebook is the retry outcome:
reject the player's command;
if the outcome of the rulebook is the parse outcome:
deactivate gender question mode.
Section 6 - To deactivate gender question mode
To deactivate gender question mode:
now the Command Prompt is the saved prompt;
now the Current Prompt is "";
now gender question mode is false.
Chapter 6 - Questions that require a text answer
Section 1 - Flag to set text question mode
Text question mode is a truth state that varies.
Punctuation removal is a truth state that varies.
Section 2 - Action for text questions
Text questioning is an action applying to one topic.
Understand "[text]" as text questioning when text question mode is true.
Understand "dici [text]" as text questioning when text question mode is true.
Section 3 - Rules for text questions
Text question rules is a rulebook.
The text question rules have outcomes exit (success), retry (failure) and parse (failure).
The first text question rule (this is the remove punctuation from text questions rule):
if punctuation removal is true:
replace the regular expression "\p" in the current answer with "";
The last text question rule (this is the default text question rule):
if closed question mode is true:
retry;
if closed question mode is false:
parse.
Section 4 - Processing text questions
After reading a command when text question mode is true:
now the current answer is the player's command;
replace the regular expression "^dici " in the current answer with "", case insensitively;
follow the text question rules;
if the outcome of the rulebook is the exit outcome:
deactivate text question mode;
follow the every turn rules;
follow the advance time rule;
reject the player's command;
if the outcome of the rulebook is the retry outcome:
reject the player's command;
if the outcome of the rulebook is the parse outcome:
deactivate text question mode.
Section 5 - To deactivate text question mode
To deactivate text question mode:
now the Command Prompt is the saved prompt;
now the Current Prompt is "";
now text question mode is false.
Chapter 7 - Real number question mode (for use with Fixed Point Maths by Michael Callaghan)
Section 1 - Default command line prompts for real numbers
Closed real number prompt is text that varies. Closed real number prompt is "Inserisci un numero >".
Open real number prompt is text that varies. Open real number prompt is ">".
Section 2 - Phrase to ask a real number question in closed mode
To ask a closed question in real number mode:
now closed question mode is true;
now saved prompt is the command prompt;
if current prompt is "":
now the command prompt is the closed real number prompt;
otherwise:
now the command prompt is the current prompt;
now real number question mode is true;
if current question is not "":
say "[current question][line break]".
Section 3 - Phrase to ask a real number question in open mode
To ask an open question in real number mode:
now closed question mode is false;
now saved prompt is the command prompt;
if current prompt is "":
now the command prompt is the open real number prompt;
otherwise:
now the command prompt is the current prompt;
now real number question mode is true;
if current question is not "":
say "[current question][line break]".
Section 4 - Flag for real number question mode
Real number question mode is a truth state that varies.
Section 5 - Action for real number questions
Real number questioning is an action applying to one real number.
Understand "[real number]" as real number questioning when real number question mode is true.
Understand "dici [real number]" as real number questioning when real number question mode is true.
Section 6 - Answer form for real numbers
Current number is a real number that varies.
Section 7 - Rules for real number questions
Real number question rules is a rulebook.
The real number question rules have outcomes exit (success), retry (failure) and parse (failure).
The first real number question rule (this is the invalid real number reply rule):
let T be indexed text;
let T be the player's command;
replace the regular expression "^dici " in T with "", case insensitively;
now the current number is the number derived from T;
if invalid conversion is true:
if closed question mode is true:
retry;
if closed question mode is false:
parse.
The last real number question rule (this is the default real number question rule):
exit.
Section 7 - Processing real number questions
After reading a command when real number question mode is true:
follow the real number question rules;
if the outcome of the rulebook is the exit outcome:
deactivate real number question mode;
follow the every turn rules;
follow the advance time rule;
reject the player's command;
if the outcome of the rulebook is the retry outcome:
reject the player's command;
if the outcome of the rulebook is the parse outcome:
deactivate real number question mode.
Section 8 - To deactivate real number question mode
To deactivate real number question mode:
now the Command Prompt is the saved prompt;
now the Current Prompt is "";
now real number question mode is false.
Chapter 8 - To decide if we are in question mode
Section 1 - Basic decision (for use without Fixed Point Maths by Michael Callaghan)
To decide if we are asking a question:
if number question mode is true:
decide yes;
if menu question mode is true:
decide yes;
if yes/no question mode is true:
decide yes;
if gender question mode is true:
decide yes;
if text question mode is true:
decide yes;
decide no.
Section 2 - Extended decision (for use with Fixed Point Maths by Michael Callaghan)
To decide if we are asking a question:
if number question mode is true:
decide yes;
if menu question mode is true:
decide yes;
if yes/no question mode is true:
decide yes;
if gender question mode is true:
decide yes;
if text question mode is true:
decide yes;
if real number question mode is true:
decide yes;
decide no.
Questions IT ends here.
---- DOCUMENTATION ----
Leggi la documentazione originale di Version 4 of Questions by Michael Callaghan.