/
Automated Testing.i7x
2283 lines (1750 loc) · 101 KB
/
Automated Testing.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
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Automated Testing by Kerkerkruip begins here.
Use authorial modesty.
Volume - Test Framework (not for release)
Include Simple Unit Tests by Dannii Willis.
Include Text Capture by Eric Eve. [Actually, this must be included before Basic Screen Effects]
Use maximum capture buffer length of at least 16384.
Use maximum text length of at least 16384.
Chapter - Randomized Events
Section - Outcomes
An outcome is a kind of value. Some outcomes are defined by the Table of outcomes.
outcome state is a kind of value. The outcome states are outcome-untested, outcome-possible, outcome-failed, and outcome-achieved.
Definition: an outcome is resolved if the state of it is at least outcome-failed.
Definition: an outcome is untested if the state of it is outcome-untested.
Definition: an outcome is possible if the state of it is outcome-possible.
Definition: an outcome is failed if the state of it is outcome-failed.
Definition: an outcome is achieved if the state of it is outcome-achieved.
An outcome can be unscheduled, scheduled for immediate testing, scheduled for later testing, just-tested, or just-succeeded.
[Outcome properties:
attempt count - number of times outcome has been tested
success count - number of times a test "succeeded"
likelihood -
minimum attempts -
The probability of a test "succeeding" should be likelihood / minimum attempts.
This has some special interpretations:
if likelihood = 0 or likelihood = minimum attempts, then success or failure of each test is considered a certainty, and the whole outcome will fail if a single test does not perform as expected
if minimum attempts = 0, then likelihood is considered a minimum number of successes, not a probability. Setting likelihood to 1 means the whole outcome will be achieved if a single test succeeds
For all other values, a tolerance range will be established that should achieve the outcome in 99.5% of cases with correctly randomized successes
maximum attempts - outcome will "time out" and fail if it reaches this number without being achieved first. If you don't set this, a reasonable default will be chosen for you
maximum tolerance - do not set, will be calculated
state - determines whether the outcome has been tested and whether more testing is needed
antecedent - the outcome that must succeed before this can be tested
]
Table of Outcomes
outcome attempt count success count likelihood (number) minimum attempts (number) maximum attempts (number) maximum tolerance (number) state (outcome state) label (text) antecedent (outcome)
boring lack of results 0 0 0 1 1 0 outcome-untested -- boring lack of results
restarting for tests 0 0 1 1 1 0 -- -- --
label-tagging relates an outcome (called the event) to a text (called the tag) when the label of the event is the tag.
The verb to be labeled means the label-tagging relation.
Section - Statistical Help
[This phrase helps us set a reasonable error tolerance of repeated tests so they will succeed most of the time. If we use a success rate of 0.995, that will set a threshold of error such that the outcome will be achieved for 99.5% of random seeds]
To set the maximum tolerance for (event - an outcome) with (success rate - a real number) achievement:
if minimum attempts of event is 0 or likelihood of event is 0 or likelihood of event is minimum attempts of event:
now maximum tolerance of event is 0;
otherwise:
Let success-target be (likelihood of event * maximum attempts of event) / (minimum attempts of event);
Let P be (likelihood of event) / (minimum attempts of event * 1.0);
Let current rate be 0.0;
Let current threshold be 0;
while current rate < success rate:
increase current rate by the probability of winning (success-target + current threshold) times out of maximum attempts of event with likelihood P;
if current threshold > 0:
increase current rate by the probability of winning (success-target - current threshold) times out of maximum attempts of event with likelihood P;
increment current threshold;
now the maximum tolerance of event is current threshold - 1;
To decide what real number is the probability of winning (K - a number) times out of (N - a number) with likelihood (P - a real number):
if K < 0 or K > N:
decide on 0.0;
let product be 1.0;
[probability = N choose K * P(success)^N * P(failure)^(K-N)]
[N choose K method cribbed from Wikipedia page on the binomial coefficient]
[interspersed with multiplying by P and 1 - P to prevent the number from getting too big or too small]
Repeat with i running from 1 to K:
now product is product * (n + 1 - i) / (i * 1.0);
now product is product * P;
if i is not greater than (N - K):
now product is product * (1 - P);
Repeat with i running from (K + 1) to (N - K):
now product is product * (1 - P);
decide on product;
[
To decide what real number is (N - a number) choose (K - a number):
Let the product be 1.0;
Repeat with i running from 1 to K:
now product is product * (n + 1 - i) / (i * 1.0);
decide on product;
]
Section - Generating Actions
For taking a player action when a person is scheduled to act freely (this is the player combat round action rule):
if the actor part of the compelled action is not the player:
generate the action of waiting;
otherwise:
generate the compelled action;
For taking a player action when testing compelling an action (this is the compel player action rule):
Let the guy be the actor part of the compelled action;
if (the player is at-act or the combat status is peace) and the guy is the player:
generate the compelled action;
forget the compelled action;
test compelling an action against true;
otherwise:
[This code could prevent infinite loops, but it might be a little overeager. Consider it a TODO:
unless (the location of the guy is the location and the combat status is combat) or the guy is acting independently:
now the failure report is "[The guy] is not available to try [the compelled action]";
test compelling an action against false;]
transcribe "[combat state of the player] player waits until [the compelled action] can be compelled";
generate the action of waiting;
schedule taking a turn;
To say (event - compelling an action):
say "compelling [the compelled action]";
For taking a player action when testing compelling a reaction (this is the compel player reaction rule):
if the actor part of the compelled action is the player and the player is at-react:
generate the compelled action;
forget the compelled action;
test compelling a reaction against true;
otherwise:
transcribe "[combat state of the player] player waits until [the compelled attacker] attacks";
generate the action of waiting;
schedule taking a turn.
For taking a player action when testing compelling an attack (this is the compel player attack rule):
if the compelled attacker is the player and the player is at-act:
generate the action of attacking (the actor part of the compelled action);
test compelling an attack against true;
schedule compelling a reaction;
otherwise:
transcribe "[combat state of the player] player waits until [the compelled attacker] can be compelled to attack";
generate the action of waiting;
schedule taking a turn.
The player combat round action rule is listed first in the for taking a player action rulebook.
The compel player action rule is listed before the player combat round action rule in the for taking a player action rulebook.
The compel player reaction rule is listed before the compel player action rule in the for taking a player action rulebook.
The compel player attack rule is listed before the compel player reaction rule in the for taking a player action rulebook.
to say (event - compelling an attack):
say "compelling [the compelled attacker] to attack [the actor part of the compelled action]";
to say (event - compelling a reaction):
say "compelling [the compelled action] as a reaction to [the compelled attacker]"
Table of Outcomes (continued)
outcome likelihood minimum attempts
taking a turn 1 0
compelling an attack 1 0
compelling an action 1 0
compelling a reaction 1 1
Definition: an outcome is schedule-blocking if it is at least taking a turn and it is at most compelling a reaction.
Regular scheduling of a schedule-blocking outcome (called the event) (this is the regular block scheduling rule):
now the event is scheduled for later testing.
[I7 names borrowed from Ron Newcomb's Original Parser]
The action in progress is an action name that varies.
The person requesting is a person that varies.
The action in progress variable translates into I6 as "action".
The person requesting variable translates into I6 as "act_requester".
To begin the current action: (- BeginAction(action, noun, second); -)
To generate (the desired action - a stored action):
transcribe "Player [if the player is at-react]re[end if]action: [the desired action]";
now the action in progress is the action name part of the desired action;
now the person asked is the actor part of the desired action;
[now the person requesting is nothing;] [not allowed in I7?]
if the person asked is not the player, now the person requesting is the player;
now the noun is the noun part of the desired action;
now the second noun is the second noun part of the desired action;
begin the current action;
The compelled attacker is an object that varies.
The compelled action is a stored action that varies. The compelled action is the action of waiting.
A person has an outcome called the act-outcome. The act-outcome of a person is usually boring lack of results.
Definition: a person is scheduled to act freely:
Let the event be the act-outcome of it;
if the event is boring lack of results, no;
decide on whether or not the event is scheduled for later testing;
Suppress npc action is a truth state that varies.
[TODO: allow everyone to act, without messing up the normal suppresion behavior]
To compel (the desired action - a stored action):
Let the guy be the actor part of the desired action;
transcribe "compelling [the desired action][if the guy is sleeping in this world] and waking up [the guy]";
if the guy is sleeping in this world, now the guy is not asleep;
Now the compelled action is the desired action;
schedule compelling an action; [this should automatically stop and wait for a turn]
To compel (the desired action - a stored action) as a reaction to (guy - a person):
Let the compelled defender be the actor part of the desired action;
transcribe "setting the compelled attacker to [the guy][if the guy is sleeping in this world] and waking [them] up[end if][if the compelled defender is sleeping in this world] and waking [the compelled defender] up[end if]";
if the guy is sleeping in this world, now the guy is not asleep;
if the compelled defender is sleeping in this world, now the compelled defender is not asleep;
Now the compelled attacker is the guy;
Now the compelled action is the desired action;
schedule compelling an attack; [this should automatically stop and wait for a turn]
To wait for (guy - a person) to act freely:
[TODO: waking or not-waking options?]
now the act-outcome of the guy is the outcome described;
now the outcome described is scheduled for later testing;
First initial scheduling of an outcome (called event) (this is the usually suppress npc action rule):
[This should be timed to suppress all npc action most of the time, but if suppression is manually disabled, we should wait to turn it back on until the test step is tested]
if event is a test step or event is a test set:
now suppress npc action is true;
To forget the/-- compelled action:
now the compelled attacker is nothing;
now the compelled action is the action of waiting;
The automated menu question answer is a number that varies.
First for reading a command when the automated menu question answer is greater than 0:
change the text of the player's command to "[the automated menu question answer]";
First after reading a command when done testing is false (this is the restart capture after reading a command rule):
[We don't need to worry about the finish the last test rule, because it restarts before we get here. The reading a command activity causes text capturing to stop, even when "text capturing is active" remains true. Normally we don't use the reading a command rulebook during automated tests, but we do it when we answer questions. This seems to fix it:]
transcribe and stop capturing text because "faked a command";
start capturing text.
To select menu question answer (N - a number):
transcribe "Selecting answer [N]";
now the automated menu question answer is N;
carry out the reading a command activity;
now the automated menu question answer is 0;
A Standard AI rule for the compelled attacker when testing compelling an attack (this is the compel an attack rule):
if the compelled attacker is at-react:
make no decision;
try the compelled attacker attacking (the actor part of the compelled action);
test compelling an attack against true;
schedule compelling a reaction;
rule succeeds.
A Standard AI rule for a person (called P) when testing compelling a reaction (this is the compel a reaction rule):
unless the actor part of the compelled action is P and P is at-React:
make no decision;
try the compelled action;
forget the compelled action;
test compelling a reaction against true;
rule succeeds.
A Standard AI rule for a person (called P) when testing compelling an action (this is the compel an action rule):
unless the actor part of the compelled action is P and P is at-Act:
make no decision;
try the compelled action;
forget the compelled action;
test compelling an action against true;
rule succeeds.
A Standard AI rule for a person (called P) (this is the suppress actions rule):
if suppress npc action is true:
if P is scheduled to act freely:
transcribe "[act-outcome of P] allows [P] to act";
otherwise if P is at-react:
transcribe "allowing [P] to react";
otherwise:
transcribe "suppressed action for [P]";
rule succeeds;
The suppress actions rule is listed before the insane people attack themselves rule in the standard AI rulebook.
The compel an action rule is listed before the suppress actions rule in the standard AI rulebook.
The compel a reaction rule is listed before the compel an action rule in the standard AI rulebook.
The compel an attack rule is listed before the compel a reaction rule in the standard AI rulebook.
Section - Testing Outcomes
To decide whether (event - an outcome) timed out:
decide on whether or not the attempt count of the event is not less than the maximum attempts of the event;
To decide whether (event - restarting for tests) timed out: no.
To decide what number is the expected successes of (event - an outcome) after (attempts - a number):
if the minimum attempts of the event is 0, decide on likelihood of the event;
decide on (likelihood of the event * attempts) / minimum attempts of the event;
The failure report is a text that varies;
To resolve (event - an outcome):
Let the tolerance be the maximum tolerance of the event;
Let target be the expected successes of the event after the maximum attempts of the event;
let the upper bound be target + tolerance;
let the lower bound be (target - tolerance) - maximum attempts of the event + attempt count of the event;
if the success count of the event is less than the lower bound or the success count of the event is greater than the upper bound:
[achievement is impossible within the maximum number of attempts]
now the state of event is outcome-failed;
if the failure report is empty:
now the failure report is "After [attempt count of the event] attempt[s], [the event] happened [success count of the event] times (not between [lower bound] and [upper bound] of target [target] for maximum attempts [maximum attempts of event] with tolerance [tolerance])";
assert failure report based on false;
otherwise if the attempt count of the event is at least the minimum attempts of the event:
now the tolerance is (tolerance * attempt count of the event) / maximum attempts of the event;
now target is expected successes of the event after the attempt count of the event;
now the upper bound is the target + tolerance;
now the lower bound is the target - tolerance;
if likelihood of the event is at least 1 and lower bound is less than 1:
now lower bound is 1;
if the success count of the event is at least lower bound and the success count of the event is at most upper bound:
now the state of event is outcome-achieved;
if the event is not preset, assert "success" based on true;
[
failure tolerance: no way end result will be within tolerance.
eg 1 in 15 with 200 attempts
success-target=13
tolerance=9
maximum failures=200-13-9=178
(max success=22, min success=4)
necessary success = min success - maximum attempts + attempts
at 196 attempts:
4 - 200 + 196 = 0
at 197:
4 - 200 + 197 = 1
]
To resolve dependents of (event - an outcome):
if the state of the event is outcome-failed or the event timed out:
if the event has unresolved dependents:
Repeat with item running through outcomes:
if item is not resolved and item depends on event:
[if the event failed, dependents fail silently. If the event succeeded, they fail noisily]
if state of the event is outcome-achieved, assert "[item] ([success count of item]/[attempt count of item]) stalled because [event] timed out after [attempt count of event - 1] attempt[s]" based on false;
now state of item is outcome-failed;
To test (event - an outcome) against (success - a truth state):
make the event testable;
[transcribe "DEBUG: test [event] against [success]";]
increment attempt count of the event;
if success is true:
increment success count of the event;
if event is resolved:
resolve dependents of the event;
otherwise:
resolve event;
[There is a subtle conflict between "success count" and "just-succeeded". "success count" is the number of times the "success" condition was met. However, if likelihood is 0, this is not really a success - it will result in a positive "error" during resolution. On the other hand, just-succeeded is only true if we got a desirable result, even if that result is false (as it should be in the case of likelihood=0). Feel free to suggest better names for these two variables]
if success is (whether or not likelihood of the event is greater than 0):
now the event is just-succeeded;
otherwise:
now the event is just-tested;
Chapter - Persistent data
Section - Outcome Persistence
The file of test outcomes is called "testoutcomes"
To save test outcomes:
Repeat through Table of Outcomes:
now the attempt count entry is the attempt count of the outcome entry;
now the success count entry is the success count of the outcome entry;
now the likelihood entry is the likelihood of the outcome entry;
now the minimum attempts entry is the minimum attempts of the outcome entry;
now the maximum attempts entry is the maximum attempts of the outcome entry;
now the state entry is the state of the outcome entry;
now the antecedent entry is the antecedent of the outcome entry;
[ingore maximum tolerance, it will be recalculated]
write file of test outcomes from table of outcomes;
To load test outcomes:
unless file of test outcomes exists, stop;
Read file of test outcomes into table of outcomes;
Repeat through table of outcomes:
if there is an attempt count entry, now the attempt count of the outcome entry is the attempt count entry;
if there is a success count entry, now the success count of the outcome entry is the success count entry;
if there is a likelihood entry, now the likelihood of the outcome entry is the likelihood entry;
if there is a minimum attempts entry, now the minimum attempts of the outcome entry is the minimum attempts entry;
if there is a maximum attempts entry, now the maximum attempts of the outcome entry is the maximum attempts entry;
[ingore maximum tolerance, it will be recalculated]
if there is a state entry, now the state of the outcome entry is the state entry;
if there is an antecedent entry, now the antecedent of the outcome entry is the antecedent entry;
Section - The Test Transcript
The file of test transcript is called "testtranscript".
The event description is a text that varies.
The damage description is a text that varies.
[globals to cut down on block copying, which is slow]
The capture mode is a number that varies.
To capture whole events: now the capture mode is 0.
To decide whether capturing whole events: decide on whether or not the capture mode is 0.
To capture damage text: now the capture mode is 1.
To decide whether capturing damage text: decide on whether or not the capture mode is 1.
The transcription reason is a text that varies.
transcription reason reporting mode is a number that varies.
To give default transcription reason: Now transcription reason reporting mode is 0.
To decide whether giving default transcription reason: Decide on whether or not transcription reason reporting mode is 0.
To give custom transcription reason: Now transcription reason reporting mode is 1.
To decide whether giving custom transcription reason: Decide on whether or not transcription reason reporting mode is 1.
To give no transcription reason: Now transcription reason reporting mode is 2.
To decide whether giving no transcription reason: Decide on whether or not transcription reason reporting mode is 2.
To log (msg - a text):
Let T be the substituted form of msg;
let currently capturing be whether or not text capturing is active;
give no transcription reason;
if currently capturing is true, transcribe and stop capturing text;
say "[line break][T]";
append "**** [T] [bracket][current test description][close bracket][line break]" to file of test transcript;
if currently capturing is true, start capturing text;
To transcribe (T - a text):
let message be "[bracket][T][close bracket][command clarification break]";
give no transcription reason;
update event description;
append "[message]" to file of test transcript;
Definition: an outcome (called event) is relevant:
while event is not boring lack of results:
if event is the scheduled event, yes;
now event is the antecedent of event;
no.
To say current test description:
unless the scheduled event is boring lack of results:
if the primary outcome is not boring lack of results:
say "[primary outcome]";
if the scheduled event is not the primary outcome:
say ", [scheduled event]";
if the outcome described is not the scheduled event and the outcome described is not boring lack of results:
say ", [the outcome described] attempt [attempt count of the outcome described]";
if the test assertion count > 0:
if the primary outcome is not boring lack of results:
say " turn [the turn count], ";
if there is a relevant achieved outcome:
say "achieved [the list of relevant achieved outcomes] | ";
if there is a relevant failed outcome:
say "failed [the list of relevant failed outcomes] | ";
repeat with event running through possible relevant outcomes:
if the number of relevant outcomes > 1 and event is not the primary outcome:
say "'[event]'";
say " [success count of event]/[attempt count of event] times | ";
say "([test assertion count] assertions)";
To decide whether the captured text is empty: (- (captured_text-->0 == 0) -)
To flush to transcript:
unless the captured text is empty:
append "[the captured text]" to file of test transcript;
if giving default transcription reason:
transcribe "transcribed during [current test description]";
otherwise if giving custom transcription reason:
transcribe "[transcription reason] [current test description]";
give default transcription reason; [for next time]
start capturing text; [and clear the captured text]
To update the/-- event description, anonymously:
if text capturing is active:
if giving default transcription reason:
now transcription reason is "updated event description -";
give custom transcription reason;
stop capturing text;
unless the captured text is empty:
now the event description is the substituted form of "[the event description][the captured text]";
flush to transcript;
To update the/-- event description because (reason - a text):
if text capturing is active:
give custom transcription reason;
now transcription reason is reason;
update event description;
To transcribe and stop capturing text/--:
if text capturing is active:
if giving default transcription reason:
now transcription reason is "stopped capturing -";
give custom transcription reason;
update the event description;
stop capturing text;
To transcribe and stop capturing text/-- because (reason - a text):
if text capturing is active:
give custom transcription reason;
now transcription reason is reason;
transcribe and stop capturing.
To clear the/-- event description:
if text capturing is active:
if giving default transcription reason:
give no transcription reason; [if we want a message when clearing event description, we have to specify one]
stop capturing text;
flush to transcript;
now the event description is "";
To clear the/-- event description because (reason - a text):
if text capturing is active:
now transcription reason is reason;
give custom transcription reason;
clear event description;
Section - Test Results
The file of test results is called "testresults".
Table of Test Results
Test Set (outcome) Total (number) Failures (number) Failure Messages (indexed text)
with 100 blank rows
Section - Test Queue
The file of test set queue is called "testqueue"
Table of Test Set Queue
Random-Seed (number) Unresolved Count (number)
0 0
with 1 blank row
To queue (T - an outcome):
make T testable;
choose row 1 in Table of Test Set Queue;
unless there is an unresolved count entry:
now the unresolved count entry is 0;
increment the unresolved count entry;
To queue all automated tests:
Repeat with T running through enabled outcomes:
queue T.
To record a test attempt:
increment the test assertion count;
increment the total assertion count;
if there is a test set of the primary outcome in Table of Test Results:
choose row with test set of primary outcome in Table of Test Results;
otherwise:
choose a blank row in Table of Test Results;
now test set entry is the primary outcome;
now total entry is 0;
now failures entry is 0;
now failure messages entry is "";
increment the total entry;
To record a/-- failure:
choose row with test set of primary outcome in Table of Test Results;
increment the assertion failures count;
increment the failures entry;
let new message be "Failure for test: [the primary outcome], step: [the scheduled event], [if the outcome described is not the scheduled event][the outcome described], [end if]assertion [the test assertion count]: [the failure report][paragraph break]";
log the new message;
now the failure messages entry is the substituted form of "[failure messages entry][new message]";
now the failure report is "";
To record a/-- failure report of/-- (msg - a text):
now the failure report is msg;
record a failure;
To say grand test summary:
let grand test total be 0;
let grand test failures be 0;
Repeat through Table of Test Results:
now grand test total is grand test total plus total entry;
now grand test failures is grand test failures plus failures entry;
choose row 1 in Table of Test Set Queue;
let total test count be (number of filled rows in Table of Test Results) plus unresolved count entry;
say "[grand test total] test[s] in [number of filled rows in Table of Test Results]/[total test count] set[s], [grand test failures] failure[s]";
if the width of the main window is at least 98:
let the remaining outcome tests be the maximum attempts of the primary outcome - attempt count of the primary outcome;
if the number of not preset possible outcomes is at least 1:
say "; testing [number of not preset possible outcomes] outcome[s] up to [remaining outcome tests] more time[s]" ;
[TODO: square these numbers with 'requeueable' count?]
To decide whether there are test results to display:
decide on whether or not the number of filled rows in Table of Test Results is at least 1;
To display test results:
log "Test results:";
Repeat through Table of Test Results:
if failures entry is 0:
transcribe "[test set entry]: [total entry] tests, all passed";
otherwise:
log "[test set entry]: [total entry] tests, [failures entry] failures";
log "[line break]Full results: [grand test summary].";
Repeat through Table of Test Results:
if failures entry is at least 1:
log "";
log "Failures for [test set entry]:";
log "[failure messages entry]";
say "To view a full transcript of all tests, see the file 'testtranscript.glkdata' in the project directory.";
Blank out the whole of Table of Test Results;
write file of test results from Table of Test Results;
if running interactively is true:
pause the game;
otherwise:
stop the game abruptly;
Section - Testing Configuration Files
The file of noninteractive tests is called "noninteractivetests".
Running interactively is a truth state that varies. Running interactively is true.
The file of random seeding (owned by another project) is called "randomseed".
Table of Initial Test Random Seed
seed value (number)
71
To decide what number is the initial test random seed:
choose row 1 in Table of Initial Test Random Seed;
decide on seed value entry.
To load testing configuration:
if file of noninteractive tests exists, now running interactively is false;
if file of random seeding exists:
read file of random seeding into Table of Initial Test Random Seed;
Setting the random seed to is an action out of world applying to one number. Understand "randomseed [number]" as setting the random seed to.
Carry out setting the random seed to:
choose row 1 in Table of Initial Test Random Seed;
Let oldseed be the seed value entry;
now the seed value entry is the number understood;
write file of random seeding from Table of Initial Test Random Seed;
say "Changed random seed from [oldseed] to [seed value entry] and saved to file."
Chapter - Controlling Text Capture
Allowing screen effects is a truth state that varies.
Section - Capture-aware Screen Clearing (in place of Section - Clearing the screen in Basic Screen Effects by Emily Short)
To clear the/-- screen:
(- AwareClearScreen(); -)
To clear only the/-- main screen:
(- AwareClearMainScreen(); -)
To clear only the/-- status line:
(- AwareClearStatus(); -).
Section - Capture-aware waiting for key-presses (in place of Section - Waiting for key-presses, quitting suddenly in Basic Screen Effects by Emily Short)
Include (-
! Wait for a safe non navigating key. The user might press Down/PgDn or use the mouse scroll wheel to scroll a page of text, so we will stop those key codes from continuing.
[ KeyPause key;
if (capture_active || ~~(+ allowing screen effects +)) {
rfalse;
}
while ( 1 )
{
key = VM_KeyChar();
#Ifdef TARGET_ZCODE;
if ( key == 63 or 129 or 130 or 132 )
{
continue;
}
#Ifnot; ! TARGET_GLULX
if ( key == -4 or -5 or -10 or -11 or -12 or -13 )
{
continue;
}
#Endif; ! TARGET_
rfalse;
}
];
[ SPACEPause i;
if (capture_active || ~~(+ allowing screen effects +)) {
rfalse;
}
while (i ~= 13 or 31 or 32)
{
i = VM_KeyChar();
}
];
! No longer used but included just in case
[ GetKey;
return VM_KeyChar();
];
[ AwareClearScreen;
if (~capture_active && (+ allowing screen effects +)) {VM_ClearScreen(0);}
];
[ AwareClearMainScreen;
if (~capture_active && (+ allowing screen effects +)) {VM_ClearScreen(2);}
];
[ AwareClearStatus;
if (~capture_active && (+ allowing screen effects +)) {VM_ClearScreen(1);}
];
-)
[ Note that this no longer waits for *any* key, but only safe keys. The user might press Down/PgDn or use the mouse scroll wheel to scroll a page of text, so we will stop those key codes from continuing. ]
To wait for any key:
(- KeyPause(); -)
To wait for the/-- SPACE key:
(- SPACEPause(); -)
Pausing the game is an activity.
To pause the/-- game:
carry out the pausing the game activity.
For pausing the game (this is the standard pausing the game rule):
say "[paragraph break]Please press SPACE to continue." (A);
wait for the SPACE key;
clear the screen.
To decide what number is the chosen letter:
(- GetKey() -)
To stop the/-- game abruptly:
(- quit; -)
Section - Enabling screen effects when testing is done
regular scheduling of boring lack of results:
now allowing screen effects is true.
Chapter - Scheduling
testing effects rules are an outcome based rulebook.
Section - Controlling Outcomes
The dependency test root is an outcome that varies. The dependency test root is boring lack of results.
[Dependency is defined differently for different outcomes. In effect, the dependency tree has two segments:
an set of preset outcomes, all preceding testing of the scheduled event
a branching tree of outcomes, all rooted at the scheduled event
When scheduling happens, all the presets will be manually made possible - often by phrases invoked within a "regular scheduling" rule. No other branches should be followed, even though many preset outcomes have multiple dependents. But all the branches of the scheduled event should be made possible. This phrase reflects that: preset outcomes only search for possible dependents, while non-preset outcomes follow all branches of "not resolved" dependents.
]
To decide whether (event - an outcome) has unresolved dependents:
repeat with item running through outcomes:
if item currently depends on event, yes;
no.
To decide whether (event - an outcome) depends on (blocker - an outcome):
Let candidate be the event;
while candidate is not boring lack of results:
now candidate is the antecedent of the candidate;
[We don't check for cyclical dependencies. Beware!]
if candidate is blocker:
decide yes;
decide no.
To decide whether (event - an outcome) currently depends on (blocker - an outcome):
unless event depends on blocker, no;
if the blocker is preset:
decide on whether or not event is possible;
otherwise:
decide on whether or not event is not resolved;
To decide what number is the calculated maximum attempts of (event - an outcome):
unless maximum attempts of event is 0:
decide on the maximum attempts of event;
Let max be 100;
if minimum attempts of event is 1:
now max is 1;
repeat with item running through outcomes:
if item depends on event:
Let dependent-max be the calculated maximum attempts of item; [TODO: multiply by minimum / likelihood?]
if dependent-max is greater than max:
now max is dependent-max;
decide on max;
[Note that INCREASING the target achievement results in SHORTER times to success - increasing target achievement broadens the range outcomes that are considered successful, by raising tolerances]
To make (event - an outcome) testable:
if event is untested:
now state of event is outcome-possible;
now maximum attempts of event is the calculated maximum attempts of event;
set the maximum tolerance for event with 0.998 achievement;
To make (event - boring lack of results) testable:
do nothing;
Definition: an outcome is test set if the antecedent of it is restarting for tests.
Definition: an outcome is test step if it is not preset and the antecedent of it is boring lack of results.
Definition: An outcome is enabled if it is a test set.
The first test set is an outcome that varies. The first test set is boring lack of results.
The next test set is an outcome that varies.
To find test sets:
[TODO: do this at start of game?]
Let item be boring lack of results;
while the first test set is boring lack of results:
now item is the outcome after item;
if item is a test set, now the first test set is item;
while the primary outcome is boring lack of results and item is not boring lack of results:
[increment after, because the primary outcome could be the first test set]
if item is requeueable, now the primary outcome is item;
now item is the outcome after item;
while the next test set is boring lack of results and item is not boring lack of results:
if item is a test set, now the next test set is item;
now item is the outcome after item;
To decide which outcome is the test set of (event - an outcome):
if the first test set is boring lack of results:
find test sets;
if event is less than the first test set:
decide on boring lack of results;
if event is at least the primary outcome:
if the next test set is boring lack of results or event is less than the next test set:
decide on the primary outcome;
While event is not boring lack of results and event is not a test set:
now event is the outcome before event;
decide on event;
Definition: An outcome (called event) is preset:
if the first test set is boring lack of results:
find test sets;
decide on whether or not event is less than the first test set.
To report an iteration because (reason - a text):
clear event description because reason;
stop capturing text;
say " .[run paragraph on]";
start capturing text;
Section - Scheduling
To decide whether testing (T - an outcome):
if T is already scheduled, yes;
if done testing is true, no;
if T is the outcome described, yes;
if T is the scheduled event, yes;
if T is the primary outcome, yes;
no;
To decide whether testing (D - a description of outcomes):
Repeat with T running through D:
if testing T, yes;
no.
Initial scheduling rules are an outcome based rulebook.
regular scheduling rules are an outcome based rulebook.
rescheduling is a truth state that varies.
The scheduled event is an outcome that varies. The scheduled event is boring lack of results.
The outcome described is an outcome that varies.
[resettable means we can reset this and all its dependents and presets, and go on to the next test step]
Definition: boring lack of results is resettable: no;
Definition: an outcome (called event) is resettable:
if event is not the scheduled event, no;
if event is not resolved, no;
repeat with item running through outcomes:
if item currently depends on event:
no;
if item is not restarting for tests and item is preset:
if item is already scheduled, no;
if item is possible, no;
yes;
[This phrase determines if an outcome should be scheduled before resetting or rescheduling the scheduled event. It may not necessarily be schedulable right now (for that we use "immediately schedulable")]
To decide whether (event - an outcome) needs scheduling:
if event is not unscheduled, no;
[transcribe "DEBUG: does [event] need scheduling?";]
if event is not the scheduled event:
if event is a test step, no;
if event is a test set, no;
Let blocker be the antecedent of the event;
While blocker is not boring lack of results:
if blocker is just-tested, no; [we need a rescheduling so the antecedent can be just-succeeded]
now blocker is the antecedent of blocker;
if the test set of event is not the primary outcome, no; [this includes presets, which are scheduled manually or by antecedent]
if event is resolved and not (event has unresolved dependents), no;
yes.
Definition: an outcome (called event) is reschedulable:
unless event is already tested, no;
Repeat with item running through outcomes:
if item depends on event:
if item is already scheduled:
no;
if item is immediately schedulable:
no;
otherwise if item is preset:
if item is already scheduled:
no;
if event has unresolved dependents, yes;
decide on whether or not event is not resolved;
To reset (event - boring lack of results):
do nothing.
To reset (event - an outcome):
if event is the scheduled event:
[transcribe "DEBUG: reset [event], which is the scheduled event";]
repeat with item running through outcomes:
if item depends on event:
reset item;
if item is preset and item is resolved and item is not restarting for tests: [why not reset restarting for tests here? I think it causes too many restarts]
reset item;
reset the antecedent of event; [resets restarting for tests if this is the primary outcome]
[otherwise:
transcribe "DEBUG: reset [event]: the scheduled event is [the scheduled event]";]
now success count of event is 0;
now attempt count of event is 0;
now state of event is outcome-untested;
now event is unscheduled;
Repeat with guy running through people:
if the act-outcome of guy is the event, now the act-outcome of guy is boring lack of results; [TODO: always do this when resetting the scheduled event?]
To prepare (event - an outcome) for rescheduling:
report an iteration because "rescheduling [event] -";
repeat with item running through outcomes:
if item is preset or item depends on event, now item is unscheduled;
now the event is unscheduled;
Definition: an outcome (called event) is already scheduled if it is scheduled for immediate testing or it is scheduled for later testing;
Definition: an outcome (called event) is already tested if it is just-tested or it is just-succeeded;
Definition: boring lack of results is immediately schedulable: no.
Definition: an outcome (called event) is immediately schedulable:
unless event needs scheduling, no;
if the antecedent of the event is not preset and antecedent of the event is not just-succeeded, no;
Let the blocker be event;
While the blocker is not boring lack of results:
if blocker is already scheduled:
no;
otherwise if blocker is not just-succeeded:
if blocker is the antecedent of the event and blocker is not preset, no;
now blocker is the antecedent of blocker;
if event is resettable, no;
if a preset outcome is scheduled for later testing, no;
Repeat with dependent running through already scheduled outcomes:
if the antecedent of dependent is the event, no;
yes;
Definition: an outcome (called event) is immediately testable:
unless event is scheduled for immediate testing, no;
if event is preset, yes;
if a preset outcome is scheduled for later testing, no;
yes.
[The scheduled event is the earliest event that can be repeated. We test it and all its dependents together. It often has major side effects,
like taking a turn. Its antecedent is always a preset - restarting for tests if it's the beginning of a set, or boring lack of results if
no antecedent has been specified.]
To schedule (the event - boring lack of results):
transcribe and stop capturing because "boring lack of results was the new event of";
say line break;
start capturing text;
To schedule (the event - an outcome):
[transcribe "DEBUG: scheduling [event]";]
if event is a test step:
now the scheduled event is event;
capture whole events;
make the event testable;
if the antecedent of event is boring lack of results or the antecedent of event is just-succeeded:
now the outcome described is the event;
now rescheduling is true;
now the event is scheduled for immediate testing;
if attempt count of the event is 0:
now rescheduling is false;
if the event is the scheduled event, log " next step: [the scheduled event]";
follow the initial scheduling rules for the event;
if the event is the scheduled event, clear event description; [this also happens when rescheduling, under "report an iteration"]
follow the regular scheduling rules for the event;
otherwise if the antecedent of the event is preset or the antecedent of the event is immediately schedulable: