-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrepresentation-bundle.js
More file actions
2240 lines (2114 loc) · 134 KB
/
Copy pathrepresentation-bundle.js
File metadata and controls
2240 lines (2114 loc) · 134 KB
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
// Copyright (c) 2026 Botos Csaba. MIT License. See LICENSE for details.
(()=>{var Je=class{constructor(){this._register={}}has(w){return w in this._register}register(w,t){this._register[w]=t}registerClass(w){this.register(w.name,w)}request(w){if(!(w in this._register))throw new Error(`Unknown registry key: '${w}'`);return this._register[w]}registerAll(w){for(let[t,s]of Object.entries(w))this.register(t,s)}},u=new Je;var vw=class e{constructor(w,t,s,o){this.x=w,this.y=t,this.w=s,this.h=o}static fromPosSize(w,t){return new e(w[0],w[1],t[0],t[1])}get left(){return this.x}set left(w){this.x=w}get top(){return this.y}set top(w){this.y=w}get right(){return this.x+this.w}get bottom(){return this.y+this.h}get width(){return this.w}get height(){return this.h}get centerx(){return this.x+Math.floor(this.w/2)}get centery(){return this.y+Math.floor(this.h/2)}get center(){return[this.centerx,this.centery]}get topleft(){return[this.x,this.y]}get size(){return[this.w,this.h]}move(w,t){return typeof w=="object"&&w!==null?new e(this.x+w.x,this.y+w.y,this.w,this.h):new e(this.x+w,this.y+t,this.w,this.h)}copy(){return new e(this.x,this.y,this.w,this.h)}colliderect(w){return this.x<w.x+w.w&&this.x+this.w>w.x&&this.y<w.y+w.h&&this.y+this.h>w.y}collidelistall(w){let t=[];for(let s=0;s<w.length;s++)this.colliderect(w[s].rect||w[s])&&t.push(s);return t}contains(w){return w.x>=this.x&&w.y>=this.y&&w.x+w.w<=this.x+this.w&&w.y+w.h<=this.y+this.h}equals(w){return this.x===w.x&&this.y===w.y&&this.w===w.w&&this.h===w.h}toString(){return`Rect(${this.x}, ${this.y}, ${this.w}, ${this.h})`}};var E=class e{constructor(...w){this.keys=Object.freeze([...w].sort())}asVector(){let w=0,t=0;for(let s of this.keys)s==="LEFT"&&(w-=1),s==="RIGHT"&&(w+=1),s==="UP"&&(t-=1),s==="DOWN"&&(t+=1);return{x:w,y:t}}equals(w){if(!(w instanceof e)||this.keys.length!==w.keys.length)return!1;for(let t=0;t<this.keys.length;t++)if(this.keys[t]!==w.keys[t])return!1;return!0}toString(){return this.keys.length===0?"noop":this.keys.join(",")}},Ze={NOOP:new E,UP:new E("UP"),DOWN:new E("DOWN"),LEFT:new E("LEFT"),RIGHT:new E("RIGHT"),SPACE:new E("SPACE"),SPACE_RIGHT:new E("SPACE","RIGHT"),SPACE_LEFT:new E("SPACE","LEFT")},Mt=Ze.NOOP;var wt=[129,199,132],ue=[25,118,210],fe=[211,47,47],et=[69,90,100],me=[250,250,250],Xs=[109,76,65],tt=[55,71,79],st=[230,81,0],Js=[255,245,157],Zs=[255,138,128],wo=[255,196,0],eo=[255,82,82],to=[255,112,67],so=[144,202,249],oo=[185,246,202],ro=[207,216,220],io=[68,90,100],no=[1,87,155],ao=[92,107,192],lo=[200,150,220],co=[255,230,230],pe={GREEN:wt,BLUE:ue,RED:fe,GRAY:et,WHITE:me,BROWN:Xs,BLACK:tt,ORANGE:st,YELLOW:Js,PINK:Zs,GOLD:wo,LIGHTRED:eo,LIGHTORANGE:to,LIGHTBLUE:so,LIGHTGREEN:oo,LIGHTGRAY:ro,DARKGRAY:io,DARKBLUE:no,PURPLE:ao,LIGHTPURPLE:lo,LIGHTPINK:co},ot={x:0,y:-1},rt={x:0,y:1},Kw={x:-1,y:0},J={x:1,y:0},yw=[ot,Kw,rt,J];function Ww(e,w){return e.x===w.x&&e.y===w.y}function ho(e){return Math.sqrt(e.x*e.x+e.y*e.y)}function Z(e){let w=ho(e);return w>0?{x:e.x/w,y:e.y/w}:{x:1,y:0}}var Sw=class{constructor(w){Array.isArray(w)?this.gridsize=w:this.gridsize=[w,w]}passiveMovement(w){let t=w.speed===null?1:w.speed;t!==0&&w.orientation!==void 0&&w._updatePosition(w.orientation,t*this.gridsize[0])}activeMovement(w,t,s){if(s==null&&(s=w.speed===null?1:w.speed),s!==0&&t!==null&&t!==void 0){let o;if(t.asVector?o=t.asVector():o=t,Ww(o,{x:0,y:0}))return;w._updatePosition(o,s*this.gridsize[0])}}distance(w,t){return Math.abs(w.top-t.top)+Math.abs(w.left-t.left)}};var fo=pe,O=class{static is_static=!1;static only_active=!1;static is_avatar=!1;static is_stochastic=!1;static color=null;static cooldown=0;static speed=null;static mass=1;static physicstype=null;static shrinkfactor=0;constructor(w){let{key:t,id:s,pos:o,size:r=[1,1],color:i,speed:n,cooldown:a,physicstype:l,rng:c,img:h,resources:f,...p}=w;this.key=t,this.id=s;let v=Array.isArray(r)?r:[r,r];this.rect=new vw(o[0],o[1],v[0],v[1]),this.lastrect=this.rect,this.alive=!0;let b=l||this.constructor.physicstype||Sw;if(this.physics=new b(v),this.speed=n??this.constructor.speed,this.cooldown=a??this.constructor.cooldown,this.img=h||null,this.color=i||this.constructor.color,this.img&&this.img.startsWith("colors/")){let S=this.img.split("/")[1],d=fo[S];d&&(this.color=d)}this._effect_data={},this.lastmove=0,this.resources=new Proxy(f?{...f}:{},{get(S,d){return typeof d=="string"&&!(d in S)&&d!=="toJSON"&&d!=="then"&&d!==Symbol.toPrimitive&&d!==Symbol.toStringTag&&d!=="inspect"&&d!=="constructor"&&d!=="__proto__"?0:S[d]},set(S,d,R){return S[d]=R,!0}}),this.just_pushed=null,this.is_static=this.constructor.is_static,this.only_active=this.constructor.only_active,this.is_avatar=this.constructor.is_avatar,this.is_stochastic=this.constructor.is_stochastic,this.mass=this.constructor.mass,this.shrinkfactor=this.constructor.shrinkfactor,this.stypes=[];for(let[S,d]of Object.entries(p))this[S]=d}update(w){this.lastrect=this.rect,this.lastmove+=1,!this.is_static&&!this.only_active&&this.physics.passiveMovement(this)}_updatePosition(w,t){let s,o;if(t==null){let r=this.speed||0;s=w.x*r,o=w.y*r}else s=w.x*t,o=w.y*t;this.lastmove>=this.cooldown&&(this.rect=this.rect.move({x:s,y:o}),this.lastmove=0)}get lastdirection(){return{x:this.rect.x-this.lastrect.x,y:this.rect.y-this.lastrect.y}}toString(){return`${this.key} '${this.id}' at (${this.rect.x}, ${this.rect.y})`}},W=class extends O{static value=1;static limit=2;static res_type=null;constructor(w){super(w),this.value=w.value!==void 0?w.value:this.constructor.value,this.limit=w.limit!==void 0?w.limit:this.constructor.limit,this.res_type=w.res_type||this.constructor.res_type}get resource_type(){return this.res_type===null?this.key:this.res_type}},de=class extends O{static is_static=!0;update(w){}_updatePosition(){throw new Error("Tried to move Immutable")}};var ge=class extends O{static color=et;static is_static=!0},ve=class extends O{static color=fe},ye=class extends W{static is_static=!0},jw=class extends O{static color=fe;static limit=1;constructor(w){super(w),this._age=0,w.limit!==void 0?this.limit=w.limit:this.limit=this.constructor.limit}update(w){super.update(w),this._age+=1,this._age>=this.limit&&w.killSprite(this)}},lw=class extends O{static draw_arrow=!1;constructor(w){super(w),this.orientation===void 0&&(this.orientation=w.orientation||J)}},qw=class extends lw{static speed=1},zw=class extends lw{static draw_arrow=!0;static speed=0;constructor(w){super(w),this._age=0,w.limit!==void 0?this.limit=w.limit:this.limit=this.constructor.limit||1}update(w){super.update(w),this._age+=1,this._age>=this.limit&&w.killSprite(this)}};zw.limit=1;var bw=class extends O{static stype=null},Se=class extends bw{static is_static=!0;static is_stochastic=!0;static color=ue},kw=class extends bw{static color=tt;static is_static=!0;constructor(w){super(w),this.counter=0,this.prob=w.prob!==void 0?w.prob:1,this.total=w.total!==void 0?w.total:null,w.cooldown!==void 0?this.cooldown=w.cooldown:this.cooldown===0&&(this.cooldown=1),this.is_stochastic=this.prob>0&&this.prob<1}update(w){w.time%this.cooldown===0&&w.randomGenerator.random()<this.prob&&(w.addSpriteCreation(this.stype,[this.rect.x,this.rect.y]),this.counter+=1),this.total&&this.counter>=this.total&&w.killSprite(this)}},Yw=class extends O{static speed=1;static is_stochastic=!0;update(w){super.update(w);let t=yw[Math.floor(w.randomGenerator.random()*yw.length)];this.physics.activeMovement(this,t)}},Qw=class extends Yw{static stype=null;constructor(w){super(w),this.fleeing=w.fleeing||!1,this.stype=w.stype||this.constructor.stype}_closestTargets(w){let t=1e100,s=[],o=w.getSprites(this.stype);for(let r of o){let i=this.physics.distance(this.rect,r.rect);i<t?(t=i,s=[r]):i===t&&s.push(r)}return s}_movesToward(w,t){let s=[],o=this.physics.distance(this.rect,t.rect);for(let r of yw){let i=this.rect.move(r),n=this.physics.distance(i,t.rect);this.fleeing&&o<n&&s.push(r),!this.fleeing&&o>n&&s.push(r)}return s}update(w){O.prototype.update.call(this,w);let t=[];for(let o of this._closestTargets(w))t.push(...this._movesToward(w,o));t.length===0&&(t=[...yw]);let s=t[Math.floor(w.randomGenerator.random()*t.length)];this.physics.activeMovement(this,s)}},be=class extends Qw{constructor(w){super({...w,fleeing:!0})}},ke=class extends kw{static color=st;static is_static=!1;constructor(w){super(w),this.orientation===void 0&&(this.orientation=w.orientation||J),this.speed=w.speed!==void 0?w.speed:1}update(w){this.lastrect=this.rect,this.lastmove+=1,!this.is_static&&!this.only_active&&this.physics.passiveMovement(this),kw.prototype.update.call(this,w)}},xe=class extends qw{static is_stochastic=!0;update(w){if(this.lastdirection.x===0){let s;this.orientation.x>0?s=1:this.orientation.x<0?s=-1:s=w.randomGenerator.random()<.5?-1:1,this.physics.activeMovement(this,{x:s,y:0})}super.update(w)}},_e=class extends lw{static is_static=!0;static color=ue;static strength=1;static draw_arrow=!0},Ee=class e extends jw{static spreadprob=1;update(w){if(super.update(w),this._age===2)for(let t of yw)w.randomGenerator.random()<(this.spreadprob||e.spreadprob)&&w.addSpriteCreation(this.name,[this.lastrect.x+t.x*this.lastrect.w,this.lastrect.y+t.y*this.lastrect.h])}};function Re(e,w){let t=[...w.active_keys].sort();for(let s=Math.max(3,t.length);s>=0;s--)for(let o of mo(t,s)){let r=o.join(",");if(e._keysToAction.has(r))return e._keysToAction.get(r)}throw new Error("No valid actions encountered, consider allowing NO_OP")}function mo(e,w){if(w===0)return[[]];if(e.length===0)return[];let t=[];function s(o,r){if(r.length===w){t.push([...r]);return}for(let i=o;i<e.length;i++)r.push(e[i]),s(i+1,r),r.pop()}return s(0,[]),t}function Ct(e){let w=new Map;for(let t of Object.values(e)){let s=[...t.keys].sort().join(",");w.set(s,t)}return w}var Vw=class extends O{static color=me;static speed=1;static is_avatar=!0;constructor(w){super(w),this.is_avatar=!0;let t=this.constructor.declarePossibleActions();this._keysToAction=Ct(t)}static declarePossibleActions(){return{UP:new E("UP"),DOWN:new E("DOWN"),LEFT:new E("LEFT"),RIGHT:new E("RIGHT"),NO_OP:new E}}update(w){O.prototype.update.call(this,w);let t=Re(this,w);t.equals(Mt)||this.physics.activeMovement(this,t)}},cw=class extends O{static color=me;static speed=1;static is_avatar=!0;static draw_arrow=!1;constructor(w){super(w),this.is_avatar=!0,this.orientation===void 0&&(this.orientation=w.orientation||J);let t=this.constructor.declarePossibleActions();this._keysToAction=Ct(t)}static declarePossibleActions(){return{UP:new E("UP"),DOWN:new E("DOWN"),LEFT:new E("LEFT"),RIGHT:new E("RIGHT"),NO_OP:new E}}update(w){let t=this.orientation;this.orientation={x:0,y:0},O.prototype.update.call(this,w);let s=Re(this,w);s&&this.physics.activeMovement(this,s);let o=this.lastdirection;Math.abs(o.x)+Math.abs(o.y)!==0?this.orientation=o:this.orientation=t}},Ae=class extends cw{static ammo=null;constructor(w){super(w),this.stype=w.stype||null,this.ammo=w.ammo!==void 0?w.ammo:this.constructor.ammo}static declarePossibleActions(){let w=cw.declarePossibleActions();return w.SPACE=new E("SPACE"),w}update(w){cw.prototype.update.call(this,w);let t=Re(this,w);this._hasAmmo()&&t.equals(Ze.SPACE)&&this._shoot(w)}_hasAmmo(){return this.ammo===null?!0:this.ammo in this.resources?this.resources[this.ammo]>0:!1}_spendAmmo(){this.ammo!==null&&this.ammo in this.resources&&(this.resources[this.ammo]-=1)}_shoot(w){if(this.stype===null)return;let t=this._shootDirections(w);for(let s of t){let o=[this.lastrect.x+s.x*this.lastrect.w,this.lastrect.y+s.y*this.lastrect.h],r=w.createSprite(this.stype,o);r&&r.orientation!==void 0&&(r.orientation=s)}this._spendAmmo()}_shootDirections(w){return[Z(this.orientation)]}},hw=class extends Vw{static declarePossibleActions(){return{LEFT:new E("LEFT"),RIGHT:new E("RIGHT"),NO_OP:new E}}update(w){O.prototype.update.call(this,w);let t=Re(this,w),s=t.asVector();(Ww(s,J)||Ww(s,Kw))&&this.physics.activeMovement(this,t)}},Ie=class extends hw{static color=wt;constructor(w){super(w),this.stype=w.stype||null}static declarePossibleActions(){let w=hw.declarePossibleActions();return w.SPACE=new E("SPACE"),w}update(w){hw.prototype.update.call(this,w),this.stype&&w.active_keys.includes("SPACE")&&w.createSprite(this.stype,[this.rect.x,this.rect.y])}};function ew(e,w,t){t.killSprite(e)}function Bt(e,w,t){t.killSprite(e),t.killSprite(w)}function Gt(e,w,t){t.addSpriteCreation(e.key,[e.rect.x,e.rect.y])}function xw(e,w,t,{stype:s="wall"}={}){let o=e.lastrect;t.killSprite(e);let r=t.addSpriteCreation(s,e.rect.topleft);r!=null&&(r.lastrect=o,e.orientation!==void 0&&r.orientation!==void 0&&(r.orientation=e.orientation))}function Pt(e,w,t,{resource:s,limit:o=1,no_symmetry:r=!1,exhaustStype:i=null}={}){e.resources[s]<o?Xw(e,w,t,{no_symmetry:r}):i?t.kill_list.includes(w)||xw(w,e,t,{stype:i}):ew(w,e,t)}function Xw(e,w,t,{no_symmetry:s=!1}={}){!t.kill_list.includes(w)&&!t.kill_list.includes(e)&&(e.rect.equals(e.lastrect)&&!s?(w.rect=w.lastrect,it(w,0)):(e.rect=e.lastrect,it(e,0)))}function it(e,w){w>5||e.just_pushed&&(e.just_pushed.rect=e.just_pushed.lastrect,it(e.just_pushed,w+1))}function Nt(e,w,t){for(let s of t.sprite_registry.sprites())s.rect=s.lastrect}function nt(e,w){return e.just_pushed&&w<3?nt(e.just_pushed,w+1):e.lastdirection}function Dt(e,w,t){let s=nt(w,0);Math.abs(s.x)+Math.abs(s.y)===0?(s=nt(e,0),w.physics.activeMovement(w,Z(s)),w.just_pushed=e):(e.physics.activeMovement(e,Z(s)),e.just_pushed=w)}function $t(e,w,t,{exhaustStype:s=null}={}){if(e.lastrect.colliderect(w.rect))return;let o=e.lastdirection;if(Math.abs(o.x)+Math.abs(o.y)===0)return;let i=Z(o),n=e.rect.width,a=e.rect.copy();a.x+=Math.round(i.x)*n,a.y+=Math.round(i.y)*n,!(a.x<0||a.y<0||a.x+a.width>t.screensize[0]||a.y+a.height>t.screensize[1])&&(e.rect=a,e.lastmove=0,s&&xw(w,e,t,{stype:s}))}function at(e,w,t,{with_step_back:s=!0}={}){s&&(e.rect=e.lastrect),e.orientation!==void 0&&(e.orientation={x:-e.orientation.x,y:-e.orientation.y})}function Ht(e,w,t){e.rect=e.lastrect,e.lastmove=e.cooldown,e.physics.activeMovement(e,{x:0,y:1},1),at(e,w,t,{with_step_back:!1})}function Ft(e,w,t){let s=[{x:0,y:-1},{x:-1,y:0},{x:0,y:1},{x:1,y:0}];e.orientation=s[Math.floor(t.randomGenerator.random()*s.length)]}function Ut(e,w,t,{offset:s=0}={}){e.rect.top<0?e.rect.top=t.screensize[1]-e.rect.height:e.rect.top+e.rect.height>t.screensize[1]&&(e.rect.top=0),e.rect.left<0?e.rect.left=t.screensize[0]-e.rect.width:e.rect.left+e.rect.width>t.screensize[0]&&(e.rect.left=0),e.lastmove=0}function Kt(e,w,t){if(!(e instanceof W))throw new Error(`collectResource: sprite must be a Resource, got ${e.constructor.name}`);let s=e.resource_type,o=t.domain.resources_limits&&t.domain.resources_limits[s]||1/0;w.resources[s]=Math.max(0,Math.min(w.resources[s]+e.value,o))}function Wt(e,w,t,{resource:s,value:o=1}={}){t.resource_changes.push([e,s,o])}function jt(e,w,t,{resource:s,value:o=1}={}){t.resource_changes.push([w,s,o]),t.kill_list.push(e)}function qt(e,w,t,{resource:s,value:o=-1}={}){t.resource_changes.push([w,s,o]),t.kill_list.push(e)}function zt(e,w,t,{resource:s,limit:o=1}={}){w.resources[s]>=o&&ew(e,w,t)}function Yt(e,w,t,{resource:s,limit:o=1}={}){e.resources[s]>=o&&ew(e,w,t)}function Qt(e,w,t,{resource:s,limit:o=1}={}){w.resources[s]<=o&&ew(e,w,t)}function Vt(e,w,t,{resource:s,limit:o=1}={}){e.resources[s]<=o&&ew(e,w,t)}function Xt(e,w,t,{resource:s,stype:o,limit:r=1}={}){e.resources[s]>=r&&t.addSpriteCreation(o,[e.rect.x,e.rect.y])}function Jt(e,w,t){t.kill_list.includes(w)||ew(e,w,t)}function Zt(e,w,t){let s=e.lastrect,o=Z(w.orientation);e.physics.activeMovement(e,o,w.strength||1),e.lastrect=s}function ws(e,w,t){if(!rs(e,t,"t_lastpull"))return;let s=e.lastrect,o=w.lastdirection,i=Math.abs(o.x)+Math.abs(o.y)>0?Z(o):{x:1,y:0};e._updatePosition(i,(w.speed||1)*e.physics.gridsize[0]),e.lastrect=s}function es(e,w,t){let s=t.sprite_registry.withStype(w.stype||w.key);if(s.length>0){let o=s[Math.floor(t.randomGenerator.random()*s.length)];e.rect=o.rect.copy()}e.lastmove=0}function ts(e,w,t,{exhaustStype:s=null}={}){if(e.lastrect.colliderect(w.rect))return;let o=t.sprite_registry.group(w.key).filter(i=>i!==w);if(o.length===0)return;let r=o[Math.floor(t.randomGenerator.random()*o.length)];e.rect=r.rect.copy(),e.lastrect=r.rect.copy(),e.lastmove=0,s&&(xw(w,e,t,{stype:s}),xw(r,e,t,{stype:s}))}function ss(e,w,t,{friction:s=0}={}){rs(e,t,"t_lastbounce")&&(e.speed!==null&&(e.speed*=1-s),Xw(e,w,t),e.orientation!==void 0&&(Math.abs(e.rect.centerx-w.rect.centerx)>Math.abs(e.rect.centery-w.rect.centery)?e.orientation={x:-e.orientation.x,y:e.orientation.y}:e.orientation={x:e.orientation.x,y:-e.orientation.y}))}function os(e,w,t,{friction:s=0}={}){if(Xw(e,w,t),e.orientation!==void 0){let o=e.orientation,r=Z({x:-e.rect.centerx+w.rect.centerx,y:-e.rect.centery+w.rect.centery}),i=r.x*o.x+r.y*o.y;e.orientation={x:-2*i*r.x+o.x,y:-2*i*r.y+o.y},e.speed!==null&&(e.speed*=1-s)}}function rs(e,w,t){return t in e._effect_data&&e._effect_data[t]===w.time?!1:(e._effect_data[t]=w.time,!0)}var _w=class{constructor({win:w=!0,scoreChange:t=0}={}){this.win=w,this.score=t}isDone(w){return[!1,null]}},Oe=class extends _w{constructor(w={}){super(w),this.limit=w.limit||0}isDone(w){return w.time>=this.limit?[!0,this.win]:[!1,null]}},Le=class extends _w{constructor(w={}){super(w),this.limit=w.limit!==void 0?w.limit:0,this.stype=w.stype||null}isDone(w){return w.numSprites(this.stype)<=this.limit?[!0,this.win]:[!1,null]}toString(){return`SpriteCounter(stype=${this.stype})`}},Te=class extends _w{constructor(w={}){let{win:t=!0,scoreChange:s=0,limit:o=0,...r}=w;super({win:t,scoreChange:s}),this.limit=o,this.stypes=[];for(let[i,n]of Object.entries(r))i.startsWith("stype")&&this.stypes.push(n)}isDone(w){let t=0;for(let s of this.stypes)t+=w.numSprites(s);return t===this.limit?[!0,this.win]:[!1,null]}},Me=class extends _w{constructor(w={}){super(w),this.stype=w.stype||null,this.limit=w.limit||0}isDone(w){let t=w.getAvatars();return t.length===0?[!1,null]:[(t[0].resources[this.stype]||0)>=this.limit,this.win]}};var Ce=class e{constructor(){this.classes={},this.classArgs={},this.stypes={},this.spriteKeys=[],this.singletons=[],this._spriteById={},this._liveSpritesByKey={},this._deadSpritesByKey={}}reset(){this._liveSpritesByKey={},this._deadSpritesByKey={},this._spriteById={}}registerSingleton(w){this.singletons.push(w)}isSingleton(w){return this.singletons.includes(w)}registerSpriteClass(w,t,s,o){if(w in this.classes)throw new Error(`Sprite key already registered: ${w}`);if(t==null)throw new Error(`Cannot register null class for key: ${w}`);this.classes[w]=t,this.classArgs[w]=s,this.stypes[w]=o,this.spriteKeys.push(w)}getSpriteDef(w){if(!(w in this.classes))throw new Error(`Unknown sprite type '${w}', verify your domain file`);return{cls:this.classes[w],args:this.classArgs[w],stypes:this.stypes[w]}}*getSpriteDefs(){for(let w of this.spriteKeys)yield[w,this.getSpriteDef(w)]}_generateIdNumber(w){let t=(this._liveSpritesByKey[w]||[]).map(r=>parseInt(r.id.split(".").pop())),s=(this._deadSpritesByKey[w]||[]).map(r=>parseInt(r.id.split(".").pop())),o=t.concat(s);return o.length>0?Math.max(...o)+1:1}generateId(w){let t=this._generateIdNumber(w);return`${w}.${t}`}createSprite(w,t){if(this.isSingleton(w)&&(this._liveSpritesByKey[w]||[]).length>0)return null;let{cls:s,args:o,stypes:r}=this.getSpriteDef(w),i=t.id||this.generateId(w),n={...o,...t,key:w,id:i},a=new s(n);return a.stypes=r,this._liveSpritesByKey[w]||(this._liveSpritesByKey[w]=[]),this._liveSpritesByKey[w].push(a),this._spriteById[i]=a,a}killSprite(w){w.alive=!1;let t=w.key,s=this._liveSpritesByKey[t];if(s){let o=s.indexOf(w);o!==-1&&(s.splice(o,1),this._deadSpritesByKey[t]||(this._deadSpritesByKey[t]=[]),this._deadSpritesByKey[t].push(w))}}group(w,t=!1){let s=this._liveSpritesByKey[w]||[];if(!t)return s;let o=this._deadSpritesByKey[w]||[];return s.concat(o)}*groups(w=!1){for(let t of this.spriteKeys)if(w){let s=this._liveSpritesByKey[t]||[],o=this._deadSpritesByKey[t]||[];yield[t,s.concat(o)]}else yield[t,this._liveSpritesByKey[t]||[]]}*sprites(w=!1){if(w)throw new Error("sprites(includeDead=true) not supported");for(let t of this.spriteKeys){let s=this._liveSpritesByKey[t]||[];for(let o of s)yield o}}spritesArray(){let w=[];for(let t of this.spriteKeys){let s=this._liveSpritesByKey[t]||[];for(let o of s)w.push(o)}return w}withStype(w,t=!1){if(this.spriteKeys.includes(w))return this.group(w,t);let s=[];for(let o of this.spriteKeys)if(this.stypes[o]&&this.stypes[o].includes(w)){let r=t?(this._liveSpritesByKey[o]||[]).concat(this._deadSpritesByKey[o]||[]):this._liveSpritesByKey[o]||[];s.push(...r)}return s}getAvatar(){for(let[,w]of this.groups(!0))if(w.length>0&&this.isAvatar(w[0]))return w[0];return null}isAvatar(w){return this.isAvatarCls(w.constructor)}isAvatarCls(w){let t=w;for(;t&&t.name;){if(t.name.includes("Avatar"))return!0;t=Object.getPrototypeOf(t)}return!1}deepCopy(){let w=new e;w.classes={...this.classes},w.classArgs={};for(let[t,s]of Object.entries(this.classArgs))w.classArgs[t]={...s};w.stypes={};for(let[t,s]of Object.entries(this.stypes))w.stypes[t]=[...s];return w.spriteKeys=[...this.spriteKeys],w.singletons=[...this.singletons],w}};var lt=class{constructor(w=42){this._seed=w,this._state=w}random(){let w=this._state+=1831565813;return w=Math.imul(w^w>>>15,w|1),w^=w+Math.imul(w^w>>>7,w|61),((w^w>>>14)>>>0)/4294967296}choice(w){return w[Math.floor(this.random()*w.length)]}seed(w){this._state=w,this._seed=w}},ct=class{constructor(w,t,{scoreChange:s=0}={}){this.actor_stype=w,this.actee_stype=t,this.score=s,this.is_stochastic=!1}call(w,t,s){throw new Error("Effect.call not implemented")}get name(){return this.constructor.name}},Jw=class extends ct{constructor(w,t,s,o={}){let r=o.scoreChange||0;super(t,s,{scoreChange:r}),this.callFn=w;let{scoreChange:i,...n}=o;this.fnArgs=n,this._name=w.name||"anonymous"}call(w,t,s){return Object.keys(this.fnArgs).length>0?this.callFn(w,t,s,this.fnArgs):this.callFn(w,t,s)}get name(){return this._name}},Ew=class{constructor(w,t={}){this.domain_registry=w,this.title=t.title||null,this.seed=t.seed!==void 0?t.seed:42,this.block_size=t.block_size||1,this.notable_resources=[],this.sprite_order=[],this.collision_eff=[],this.char_mapping={},this.terminations=[],this.resources_limits={},this.resources_colors={},this.is_stochastic=!1}finishSetup(){this.is_stochastic=this.collision_eff.some(t=>t.is_stochastic),this.setupResources();let w=this.sprite_order.indexOf("avatar");w!==-1&&(this.sprite_order.splice(w,1),this.sprite_order.push("avatar"))}setupResources(){this.notable_resources=[];for(let[w,{cls:t,args:s}]of this.domain_registry.getSpriteDefs())if(t.prototype instanceof W||t===W){let o=w;s.res_type&&(o=s.res_type),s.color&&(this.resources_colors[o]=s.color),s.limit!==void 0&&(this.resources_limits[o]=s.limit),this.notable_resources.push(o)}}buildLevel(w){let t=w.split(`
`).filter(n=>n.length>0),s=t.map(n=>n.length),o=Math.min(...s),r=Math.max(...s);if(o!==r)throw new Error(`Inconsistent line lengths: min=${o}, max=${r}`);let i=new ht(this,this.domain_registry.deepCopy(),w,s[0],t.length,this.seed);for(let n=0;n<t.length;n++)for(let a=0;a<t[n].length;a++){let l=t[n][a],c=this.char_mapping[l];if(c){let h=[a*this.block_size,n*this.block_size];i.createSprites(c,h)}}return i.initState=i.getGameState(),i}},ht=class{constructor(w,t,s,o,r,i=0){this.domain=w,this.sprite_registry=t,this.levelstring=s,this.width=o,this.height=r,this.block_size=w.block_size,this.screensize=[this.width*this.block_size,this.height*this.block_size],this.seed=i,this.randomGenerator=new lt(i),this.kill_list=[],this.create_list=[],this.resource_changes=[],this.score=0,this.last_reward=0,this.time=0,this.ended=!1,this.won=!1,this.lose=!1,this.is_stochastic=!1,this.active_keys=[],this.events_triggered=[],this.initState=null,this._gameRect=new vw(0,0,this.screensize[0],this.screensize[1])}reset(){this.score=0,this.last_reward=0,this.time=0,this.ended=!1,this.won=!1,this.lose=!1,this.kill_list=[],this.create_list=[],this.resource_changes=[],this.active_keys=[],this.events_triggered=[],this.initState&&this.setGameState(this.initState)}createSprite(w,t,s){let o=this.sprite_registry.createSprite(w,{pos:t,id:s,size:[this.block_size,this.block_size],rng:this.randomGenerator});return o&&(this.is_stochastic=this.domain.is_stochastic||o.is_stochastic||this.is_stochastic),o}createSprites(w,t){return w.map(s=>this.createSprite(s,t)).filter(Boolean)}killSprite(w){this.kill_list.push(w)}addSpriteCreation(w,t,s){return this.create_list.push([w,t,s]),null}addScore(w){this.score+=w,this.last_reward+=w}numSprites(w){return this.sprite_registry.withStype(w).length}getSprites(w){return this.sprite_registry.withStype(w)}getAvatars(){let w=[];for(let[,t]of this.sprite_registry.groups(!0))t.length>0&&this.sprite_registry.isAvatar(t[0])&&w.push(...t);return w}containsRect(w){return this._gameRect.contains(w)}tick(w){if(this.time+=1,this.last_reward=0,this.ended)return;this.active_keys=w.keys;let t=this.sprite_registry.spritesArray();for(let a of t)a.just_pushed=null;for(let a of t)a.update(this);this.events_triggered=[];let[s,o,r]=this._moveEventHandling(),[i,n]=this._eventHandling(s);this.events_triggered=o.concat(i);for(let a of this.kill_list)this.sprite_registry.killSprite(a);for(let[a,l,c]of this.create_list)this.createSprite(a,l,c);for(let[a,l,c]of this.resource_changes){let h=this.domain.resources_limits&&this.domain.resources_limits[l]||1/0;a.resources[l]=Math.max(0,Math.min(a.resources[l]+c,h))}this._checkTerminations(),this.kill_list=[],this.create_list=[],this.resource_changes=[]}_moveEventHandling(){let w=[],t=[],s={},o=this.domain.collision_eff.filter(i=>i.name==="stepBack"||i.name==="stepBackIfHasLess");for(let i of o){let[,n,a]=this._applyEffect(i,s);w.push(...n),t.push(...a)}let r=this.domain.collision_eff.filter(i=>["bounceForward","reverseDirection","turnAround"].includes(i.name));for(let i of r){let[,n,a]=this._applyEffect(i,s);w.push(...n),t.push(...a)}for(let i of o){let[,n,a]=this._applyEffect(i,s);w.push(...n),t.push(...a)}return[s,w,t]}_eventHandling(w){let t=[],s=[],o=this.domain.collision_eff.filter(r=>!["stepBack","stepBackIfHasLess","bounceForward","reverseDirection","turnAround"].includes(r.name));for(let r of o){let[,i,n]=this._applyEffect(r,w);t.push(...i),s.push(...n)}return[t,s]}_applyEffect(w,t){let s=[],o=[],r=w.actor_stype,i=w.actee_stype;if(r in t||(t[r]=this.sprite_registry.withStype(r)),i!=="EOS"&&!(i in t)&&(t[i]=this.sprite_registry.withStype(i)),i==="EOS"){let c=t[r];for(let h=c.length-1;h>=0;h--){let f=c[h];this.containsRect(f.rect)||(this.addScore(w.score),w.call(f,null,this),s.push([w.name,f.id,"EOS"]),o.push([w.name,f.key,"EOS",[f.rect.x,f.rect.y],[null,null]]),!this.containsRect(f.rect)&&f.alive&&this.killSprite(f))}return[t,s,o]}let n=t[r],a=t[i];if(n.length===0||a.length===0)return[t,s,o];let l=!1;n.length>a.length&&([n,a]=[a,n],l=!0);for(let c of n)for(let h of a)c!==h&&c.rect.colliderect(h.rect)&&(l?this.kill_list.includes(h)||(this.addScore(w.score),w.call(h,c,this),s.push([w.name,h.id,c.id]),o.push([w.name,h.key,c.key,[h.rect.x,h.rect.y],[c.rect.x,c.rect.y]])):this.kill_list.includes(c)||(this.addScore(w.score),w.call(c,h,this),s.push([w.name,c.id,h.id]),o.push([w.name,c.key,h.key,[c.rect.x,c.rect.y],[h.rect.x,h.rect.y]])));return[t,s,o]}_checkTerminations(){this.lose=!1;for(let w of this.domain.terminations){let[t,s]=w.isDone(this);if(this.ended=t,this.won=s===null?!1:s,w.constructor.name==="Timeout"||["SpriteCounter","MultiSpriteCounter"].includes(w.constructor.name)&&this.ended&&!this.won&&(this.lose=!0),this.ended){this.addScore(w.score);break}}}getGameState(){let w={};for(let t of this.sprite_registry.spriteKeys){let s=this.sprite_registry._liveSpritesByKey[t]||[],o=this.sprite_registry._deadSpritesByKey[t]||[];w[t]=[...s,...o].map(r=>({id:r.id,key:r.key,x:r.rect.x,y:r.rect.y,w:r.rect.w,h:r.rect.h,alive:r.alive,resources:{...r.resources},speed:r.speed,cooldown:r.cooldown,orientation:r.orientation?{...r.orientation}:void 0,_age:r._age,lastmove:r.lastmove}))}return{score:this.score,time:this.time,sprites:w}}setGameState(w){this.sprite_registry.reset(),this.score=w.score,this.time=w.time;for(let[t,s]of Object.entries(w.sprites))for(let o of s){let r=this.sprite_registry.createSprite(t,{id:o.id,pos:[o.x,o.y],size:[o.w,o.h],rng:this.randomGenerator});r&&(r.resources=new Proxy({...o.resources},{get(i,n){return typeof n=="string"&&!(n in i)&&n!=="toJSON"&&n!=="then"&&n!==Symbol.toPrimitive&&n!==Symbol.toStringTag&&n!=="inspect"&&n!=="constructor"&&n!=="__proto__"?0:i[n]},set(i,n,a){return i[n]=a,!0}}),o.speed!==void 0&&(r.speed=o.speed),o.cooldown!==void 0&&(r.cooldown=o.cooldown),o.orientation&&(r.orientation={...o.orientation}),o._age!==void 0&&(r._age=o._age),o.lastmove!==void 0&&(r.lastmove=o.lastmove),r.alive=o.alive,o.alive||this.sprite_registry.killSprite(r))}}};function is(){u.register("VGDLSprite",O),u.register("Immovable",ge),u.register("Passive",ve),u.register("Resource",W),u.register("ResourcePack",ye),u.register("Flicker",jw),u.register("OrientedFlicker",zw),u.register("OrientedSprite",lw),u.register("Missile",qw),u.register("SpawnPoint",kw),u.register("SpriteProducer",bw),u.register("Portal",Se),u.register("RandomNPC",Yw),u.register("Chaser",Qw),u.register("Fleeing",be),u.register("Bomber",ke),u.register("Walker",xe),u.register("Conveyor",_e),u.register("Spreader",Ee),u.register("Immutable",de),u.register("MovingAvatar",Vw),u.register("OrientedAvatar",cw),u.register("ShootAvatar",Ae),u.register("HorizontalAvatar",hw),u.register("FlakAvatar",Ie),u.register("killSprite",ew),u.register("killBoth",Bt),u.register("cloneSprite",Gt),u.register("transformTo",xw),u.register("stepBack",Xw),u.register("stepBackIfHasLess",Pt),u.register("undoAll",Nt),u.register("bounceForward",Dt),u.register("catapultForward",$t),u.register("reverseDirection",at),u.register("turnAround",Ht),u.register("flipDirection",Ft),u.register("wrapAround",Ut),u.register("collectResource",Kt),u.register("changeResource",Wt),u.register("addResource",jt),u.register("removeResource",qt),u.register("killIfOtherHasMore",zt),u.register("killIfHasMore",Yt),u.register("killIfOtherHasLess",Qt),u.register("killIfHasLess",Vt),u.register("spawnIfHasMore",Xt),u.register("killIfAlive",Jt),u.register("conveySprite",Zt),u.register("pullWithIt",ws),u.register("teleportToExit",es),u.register("teleportToOther",ts),u.register("wallBounce",ss),u.register("bounceDirection",os),u.register("Timeout",Oe),u.register("SpriteCounter",Le),u.register("MultiSpriteCounter",Te),u.register("ResourceCounter",Me),u.register("GridPhysics",Sw),u.register("BasicGame",Ew);for(let[e,w]of Object.entries(pe))u.register(e,w);u.register("UP",ot),u.register("DOWN",rt),u.register("LEFT",Kw),u.register("RIGHT",J)}var Be=class{constructor(w,t=30){this.canvas=w,this.ctx=w.getContext("2d"),this.cellSize=t}resize(w,t){this.canvas.width=w*this.cellSize,this.canvas.height=t*this.cellSize}clear(){this.ctx.fillStyle="rgb(207, 216, 220)",this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)}render(w){this.clear();let t=w.block_size,s=this.cellSize/t;for(let o of w.domain.sprite_order){let r=w.sprite_registry._liveSpritesByKey[o]||[];for(let i of r)this._drawSprite(i,s,t)}this._drawHUD(w)}_drawSprite(w,t,s){let o=w.rect.x*t,r=w.rect.y*t,i=w.rect.w*t,n=w.rect.h*t,a=null,l=null;if(w.img){let b=this._parseImg(w.img);a=b.color,l=b.shape}a||(a=w.color),a||(a=[128,128,128]);let c=w.shrinkfactor||0,h=o+i*c/2,f=r+n*c/2,p=i*(1-c),v=n*(1-c);this.ctx.fillStyle=`rgb(${a[0]}, ${a[1]}, ${a[2]})`,l?this._drawShape(l,h,f,p,v):this.ctx.fillRect(h,f,p,v),w.orientation&&w.draw_arrow&&this._drawArrow(h,f,p,v,w.orientation,a),w.is_avatar&&this._drawResources(w,h,f,p,v)}_parseImg(w){let t={LIGHTGRAY:[207,216,220],BLUE:[25,118,210],YELLOW:[255,245,157],BLACK:[55,71,79],ORANGE:[230,81,0],PURPLE:[92,107,192],BROWN:[109,76,65],PINK:[255,138,128],GREEN:[129,199,132],RED:[211,47,47],WHITE:[250,250,250],GOLD:[255,196,0],LIGHTRED:[255,82,82],LIGHTORANGE:[255,112,67],LIGHTBLUE:[144,202,249],LIGHTGREEN:[185,246,202],LIGHTPURPLE:[200,150,220],LIGHTPINK:[255,230,230],DARKGRAY:[68,90,100],DARKBLUE:[1,87,155],GRAY:[69,90,100]};if(w.startsWith("colors/")){let s=w.split("/")[1];return{color:t[s]||null,shape:null}}if(w.startsWith("colored_shapes/")){let s=w.split("/")[1],o=["CIRCLE","TRIANGLE","DIAMOND","STAR","CROSS","HEXAGON","SQUARE","PENTAGON"];for(let r of o)if(s.endsWith("_"+r)){let i=s.slice(0,-(r.length+1));return{color:t[i]||null,shape:r}}return{color:null,shape:null}}return{color:null,shape:null}}_drawShape(w,t,s,o,r){let i=this.ctx,n=t+o/2,a=s+r/2,l=o/2,c=r/2,h=2/24,f=l*(1-2*h),p=c*(1-2*h);switch(i.beginPath(),w){case"CIRCLE":i.ellipse(n,a,f,p,0,0,Math.PI*2);break;case"TRIANGLE":{let v=a-p,b=a+p,S=n-f,d=n+f;i.moveTo(n,v),i.lineTo(d,b),i.lineTo(S,b),i.closePath();break}case"DIAMOND":i.moveTo(n,a-p),i.lineTo(n+f,a),i.lineTo(n,a+p),i.lineTo(n-f,a),i.closePath();break;case"STAR":{let v=Math.min(f,p),b=v*.4;for(let S=0;S<5;S++){let d=-Math.PI/2+S*(2*Math.PI/5),R=d+Math.PI/5;S===0?i.moveTo(n+v*Math.cos(d),a+v*Math.sin(d)):i.lineTo(n+v*Math.cos(d),a+v*Math.sin(d)),i.lineTo(n+b*Math.cos(R),a+b*Math.sin(R))}i.closePath();break}case"CROSS":{let v=f*2/3,b=v/2;i.rect(n-f,a-b,f*2,v),i.rect(n-b,a-p,v,p*2);break}case"HEXAGON":{let v=Math.min(f,p);for(let b=0;b<6;b++){let S=Math.PI/6+b*(Math.PI/3),d=n+v*Math.cos(S),R=a+v*Math.sin(S);b===0?i.moveTo(d,R):i.lineTo(d,R)}i.closePath();break}case"SQUARE":{let v=Math.min(f,p)*.05;i.rect(n-f+v,a-p+v,(f-v)*2,(p-v)*2);break}case"PENTAGON":{let v=Math.min(f,p);for(let b=0;b<5;b++){let S=-Math.PI/2+b*(2*Math.PI/5),d=n+v*Math.cos(S),R=a+v*Math.sin(S);b===0?i.moveTo(d,R):i.lineTo(d,R)}i.closePath();break}default:i.rect(t,s,o,r)}i.fill()}_drawArrow(w,t,s,o,r,i){let n=w+s/2,a=t+o/2,l=Math.min(s,o)*.3,c=[i[0],255-i[1],i[2]];this.ctx.strokeStyle=`rgb(${c[0]}, ${c[1]}, ${c[2]})`,this.ctx.lineWidth=2,this.ctx.beginPath(),this.ctx.moveTo(n,a),this.ctx.lineTo(n+r.x*l,a+r.y*l),this.ctx.stroke()}_drawResources(w,t,s,o,r){let i=w.resources,n=0,a=3;for(let l of Object.keys(i)){if(l==="toJSON")continue;let c=i[l];if(c>0){let h=s+r+n*(a+1);this.ctx.fillStyle="#FFD400",this.ctx.fillRect(t,h,o*Math.min(c/5,1),a),n++}}}_drawHUD(w){this.ctx.fillStyle="white",this.ctx.font="14px monospace",this.ctx.textAlign="left";let t=this.canvas.height-5;this.ctx.fillText(`Score: ${w.score} Time: ${w.time}`,5,t),w.ended&&(this.ctx.fillStyle=w.won?"#0f0":"#f00",this.ctx.font="bold 24px monospace",this.ctx.textAlign="center",this.ctx.fillText(w.won?"WIN":"LOSE",this.canvas.width/2,this.canvas.height/2))}};function ns(e){if(!e.delta_encoded)return;let w=e.states;if(!w||w.length<2){delete e.delta_encoded;return}let t=w[0].sprites;for(let s=1;s<w.length;s++){if(!("sprites"in w[s]))w[s].sprites=Object.assign({},t);else{let o=Object.assign({},t,w[s].sprites);for(let r in o)o[r]===null&&delete o[r];w[s].sprites=o}t=w[s].sprites}delete e.delta_encoded}var Ge=class{constructor(w,t,s=null){this.children=[],this.content=w,this.indent=t,this.parent=null,s&&s.insert(this)}insert(w){if(this.indent<w.indent){if(this.children.length>0&&this.children[0].indent!==w.indent)throw new Error(`Children indentations must match: expected ${this.children[0].indent}, got ${w.indent}`);this.children.push(w),w.parent=this}else{if(!this.parent)throw new Error("Root node too indented?");this.parent.insert(w)}}getRoot(){return this.parent?this.parent.getRoot():this}toString(){return this.children.length===0?this.content:this.content+"["+this.children.map(w=>w.toString()).join(", ")+"]"}};function po(e,w=8){e=e.replace(/\t/g," ".repeat(w));let t=e.split(`
`),s=new Ge("",-1);for(let o of t){o.includes("#")&&(o=o.split("#")[0]);let r=o.trim();if(r.length>0){let i=o.length-o.trimStart().length;s=new Ge(r,i,s)}}return s.getRoot()}var Pe=class{constructor(){this.verbose=!1}parseGame(w,t={}){let s=w;typeof s=="string"&&(s=po(s).children[0]);let[o,r]=this._parseArgs(s.content);Object.assign(r,t),this.spriteRegistry=new Ce,this.game=new Ew(this.spriteRegistry,r);for(let i of s.children)i.content.startsWith("SpriteSet")&&this.parseSprites(i.children),i.content==="InteractionSet"&&this.parseInteractions(i.children),i.content==="LevelMapping"&&this.parseMappings(i.children),i.content==="TerminationSet"&&this.parseTerminations(i.children);return this.game.finishSetup(),this.game}_eval(w){if(u.has(w))return u.request(w);let t=Number(w);return isNaN(t)?w==="True"||w==="true"?!0:w==="False"||w==="false"?!1:w:t}_parseArgs(w,t=null,s=null){s||(s={});let o=w.split(/\s+/).filter(r=>r.length>0);if(o.length===0)return[t,s];o[0].includes("=")||(t=this._eval(o[0]),o.shift());for(let r of o){let i=r.indexOf("=");if(i===-1)continue;let n=r.substring(0,i),a=r.substring(i+1);s[n]=this._eval(a)}return[t,s]}parseSprites(w,t=null,s={},o=[]){for(let r of w){if(!r.content.includes(">"))throw new Error(`Expected '>' in sprite definition: ${r.content}`);let[i,n]=r.content.split(">").map(h=>h.trim()),[a,l]=this._parseArgs(n,t,{...s}),c=[...o,i];if("singleton"in l&&(l.singleton===!0&&this.spriteRegistry.registerSingleton(i),delete l.singleton),r.children.length===0){this.verbose&&console.log("Defining:",i,a,l,c),this.spriteRegistry.registerSpriteClass(i,a,l,c);let h=this.game.sprite_order.indexOf(i);h!==-1&&this.game.sprite_order.splice(h,1),this.game.sprite_order.push(i)}else this.parseSprites(r.children,a,l,c)}}parseInteractions(w){for(let t of w){if(!t.content.includes(">"))continue;let[s,o]=t.content.split(">").map(a=>a.trim()),[r,i]=this._parseArgs(o),n=s.split(/\s+/).filter(a=>a.length>0);for(let a=1;a<n.length;a++){let l=n[0],c=n[a],h;if(typeof r=="function"&&!r.prototype)h=new Jw(r,l,c,i);else if(typeof r=="function")h=new Jw(r,l,c,i);else throw new Error(`Unknown effect type: ${r}`);this.game.collision_eff.push(h)}}}parseTerminations(w){for(let t of w){let[s,o]=this._parseArgs(t.content);this.game.terminations.push(new s(o))}}parseMappings(w){for(let t of w){let[s,o]=t.content.split(">").map(i=>i.trim());if(s.length!==1)throw new Error(`Only single character mappings allowed, got: '${s}'`);let r=o.split(/\s+/).filter(i=>i.length>0);this.game.char_mapping[s]=r}}};var ut={roomworld:{description:`BasicGame
SpriteSet
floor > Immovable img=colors/LIGHTGRAY
wall > Immovable img=colors/DARKGRAY
avatar > MovingAvatar img=colored_shapes/YELLOW_CIRCLE
goal > Immovable img=colored_shapes/LIGHTGREEN_STAR
key1 > Resource img=colored_shapes/ORANGE_DIAMOND limit=1
door1 > Immovable img=colored_shapes/ORANGE_SQUARE
door1_used > Immovable img=colored_shapes/LIGHTORANGE_SQUARE
key6 > Resource img=colored_shapes/BLUE_DIAMOND limit=1
door2 > Immovable img=colored_shapes/RED_SQUARE
teleporter > Immovable img=colored_shapes/PURPLE_HEXAGON
catapult > Immovable img=colored_shapes/PINK_TRIANGLE
catapult_used > Immovable img=colored_shapes/LIGHTPINK_TRIANGLE
t6 > Portal stype=t6 img=colored_shapes/PURPLE_HEXAGON
t6_used > Immovable img=colored_shapes/LIGHTPURPLE_HEXAGON
t3 > Immovable img=colored_shapes/GREEN_HEXAGON
key4 > Resource img=colored_shapes/GREEN_DIAMOND limit=1
c6 > Immovable img=colored_shapes/RED_TRIANGLE
door6 > Immovable img=colored_shapes/BLUE_SQUARE
door6_used > Immovable img=colored_shapes/LIGHTBLUE_SQUARE
tp4 > Portal stype=tp4 img=colored_shapes/ORANGE_HEXAGON
tp4_used > Immovable img=colored_shapes/LIGHTORANGE_HEXAGON
LevelMapping
. > floor
w > floor wall
A > floor avatar
x > floor goal
K > floor key1
D > floor door1
k > floor key6
d > floor door2
t > floor teleporter
c > floor catapult
T > floor t6
S > floor t3
e > floor key4
F > floor c6
G > floor door6
P > floor tp4
InteractionSet
avatar wall > stepBack
avatar door1 > stepBackIfHasLess resource=key1 limit=1 exhaustStype=door1_used
avatar door1_used > stepBack
avatar door2 > stepBack
avatar door6 > stepBackIfHasLess resource=key6 limit=1 exhaustStype=door6_used
avatar door6_used > stepBack
avatar catapult > catapultForward exhaustStype=catapult_used
avatar key1 > changeResource resource=key1 value=1
key1 avatar > killSprite
avatar key6 > changeResource resource=key6 value=1
key6 avatar > killSprite
avatar t6 > teleportToOther exhaustStype=t6_used
avatar tp4 > teleportToOther exhaustStype=tp4_used
avatar key4 > changeResource resource=key4 value=1
key4 avatar > killSprite
goal avatar > killSprite
floor EOS > killSprite
wall EOS > killSprite
avatar EOS > killSprite
goal EOS > killSprite
key1 EOS > killSprite
door1 EOS > killSprite
door1_used EOS > killSprite
key6 EOS > killSprite
door2 EOS > killSprite
teleporter EOS > killSprite
catapult EOS > killSprite
catapult_used EOS > killSprite
t6 EOS > killSprite
t6_used EOS > killSprite
t3 EOS > killSprite
key4 EOS > killSprite
c6 EOS > killSprite
door6 EOS > killSprite
door6_used EOS > killSprite
tp4 EOS > killSprite
tp4_used EOS > killSprite
TerminationSet
SpriteCounter stype=goal limit=0 win=True
Timeout limit=500 win=False`,levels:{0:`wwwwwwwwwwwww
w...w...D...w
w...w.K.w.x.w
w...wA..w...w
wwwwwwwwwwwww
w...w.t.w...w
w...w...wc..w
w..kw...w...w
wwdwwwwwwwwww
w...w...w...w
w...w...w...w
w...w...w...w
wwwwwwwwwwwww`,1:`wwwwwwwwwwwww
w...w...w.F.w
w...w...w...w
w...w...w...w
wwwwwwwwwwwww
w...w..Tw...w
w...w.A.w...w
w...w...wS..w
wwwwwwwwwwwww
w...w.T.w...w
w...w...w...w
w.e.w.x.w.c.w
wwwwwwwwwwwww`,2:`wwwwwwwwwwwww
w..Kw...w...w
w...w...w...w
w...w.t.w...w
wwwwwwwwwwwww
w...w.c.w...w
w...w...w..Aw
w...w...w.c.w
wwwwwwwwwwwww
w...w...w..xw
w...wc..w...w
w...w...w...w
wwwwwwwwwwwww`,3:`wwwwwwwwwwwww
w..Pw...w...w
w...w...wc..w
w...w...w...w
wwwwwwwwwwwDw
w.c.G...w...w
wt..wT..w...w
w...wSAkwKT.w
wwwwwwwwwwwww
w...w...d...w
w...w...w..xw
we..w...wP..w
wwwwwwwwwwwww`}},avoidGeorge_vgfmri4:{description:`BasicGame
SpriteSet
floor > Immovable img=colors/LIGHTGRAY
annoyed > RandomNPC speed=0.25 cons=2 img=colors/PURPLE
quiet > RandomNPC speed=0.25 cons=1 img=colors/PINK
avatar > ShootAvatar stype=cigarette img=colors/DARKBLUE
george > Chaser stype=quiet img=colors/YELLOW speed=0.15 frameRate=8
cigarette > Flicker img=colors/BROWN limit=5 rotateInPlace=False singleton=True
wall > Immovable img=colors/PURPLE
LevelMapping
. > floor
g > floor george
c > floor quiet
A > floor avatar
w > floor wall
InteractionSet
quiet george > transformTo stype=annoyed
avatar george > killSprite scoreChange=-1
annoyed cigarette > transformTo stype=quiet scoreChange=1
annoyed wall > stepBack
quiet wall > stepBack
avatar wall > stepBack
george wall > stepBack
floor EOS > killSprite
annoyed EOS > killSprite
quiet EOS > killSprite
avatar EOS > killSprite
george EOS > killSprite
cigarette EOS > killSprite
wall EOS > killSprite
TerminationSet
SpriteCounter stype=avatar win=False
SpriteCounter stype=quiet win=False
Timeout limit=400 win=True`,levels:{0:`wwwwwwwwwwwwwwwwwwwww
w...................w
w.......A......wwwwww
w.........w.........w
wwwww.....w.........w
w.........w.........w
w...................w
w...................w
w..............c....w
w...................w
w...................w
wwwwwwwwwwwwwwwwwwwww`,1:`wwwwwwwwwwwwwwwwwwwww
w....w........w.....w
w....w........w.....w
w....w........w.....w
w.................g.w
w...................w
w...................w
wwwwwww.....w.......w
w.....w.....w.......w
w.c...w.....w....A..w
w.....w.....w.......w
wwwwwwwwwwwwwwwwwwwww`,2:`wwwwwwwwwwwwwwwwwwwww
w.........w.........w
w...................w
w.......A...........w
www.....ww.ww.....www
w...................w
w..........c........w
w...................w
w...g...............w
w.........w.........w
w.........w.........w
wwwwwwwwwwwwwwwwwwwww`,3:`wwwwwwwwwwwwwwwwwwwww
w.....wwwwwww....A..w
w...................w
w...................w
w...................w
w.....wwwwwww.......w
w.....w.............w
w.....w..........c..w
w.....w.............w
w.....wwwwwww...c...w
w...................w
wwwwwwwwwwwwwwwwwwwww`,4:`wwwwwwwwwwwwwwwwwwwww
w.....wwwwwww....A..w
w...................w
w.......g...........w
w...................w
w.....wwwwwww.......w
w.....w.............w
w.....w.............w
w.....w.............w
w.....wwwwwww..c....w
w.................c.w
wwwwwwwwwwwwwwwwwwwww`,5:`wwwwwwwwwwwwwwwwwwwww
w......c............w
w...................w
w.......A.w........gw
w........www........w
w.........w.........w
w...................w
w............c......w
w...................w
w.c.................w
w...................w
wwwwwwwwwwwwwwwwwwwww`,6:`wwwwwwwwwwwwwwwwwwwww
wc...w.....w........w
w....w.....w........w
w....w.....w.....A..w
w...................w
w...................w
w......c............w
w...................w
w....g.......w......w
w............w......w
w............w..c...w
wwwwwwwwwwwwwwwwwwwww`,7:`wwwwwwwwwwwwwwwwwwwww
w.........g.........w
w...c..www........c.w
w...................w
w..A................w
w...wwwww...........w
w...................w
w....wwwww..........w
w.g.............c...w
w....wwwww..........w
w...................w
wwwwwwwwwwwwwwwwwwwww`,8:`wwwwwwwwwwwwwwwwwwwww
www........A.......ww
ww...c..............w
w..............c....w
w.g............wwwwww
w.........c.........w
www.................w
w..................ww
www.................w
wc..................w
w...................w
wwwwwwwwwwwwwwwwwwwww`}},bait_vgfmri3:{description:`BasicGame
SpriteSet
floor > Immovable img=colors/LIGHTGRAY
hole > Immovable img=colors/BLUE
avatar > MovingAvatar img=colors/DARKBLUE
mushroom > Immovable img=colors/RED
key > Resource img=colors/ORANGE limit=1
goal > Immovable img=colors/GREEN
box > Passive img=colors/BROWN
wall > Immovable img=colors/DARKGRAY
LevelMapping
. > floor
w > floor wall
A > floor avatar
0 > floor hole
1 > floor box
k > floor key
g > floor goal
m > floor mushroom
InteractionSet
avatar wall > stepBack
avatar hole > killSprite
box avatar > bounceForward
box wall > stepBack
box box > stepBack
box mushroom > undoAll
hole box > killSprite scoreChange=1
box hole > killSprite
avatar key > changeResource resource=key value=1 scoreChange=1
key avatar > killSprite
goal avatar > killIfOtherHasMore resource=key limit=1
mushroom avatar > killSprite scoreChange=1
floor EOS > killSprite
hole EOS > killSprite
avatar EOS > killSprite
mushroom EOS > killSprite
key EOS > killSprite
goal EOS > killSprite
box EOS > killSprite
wall EOS > killSprite
TerminationSet
Timeout limit=600 win=False
SpriteCounter stype=goal limit=0 win=True
SpriteCounter stype=avatar limit=0 win=False`,levels:{0:`wwwwwwwwwwwwwwwwwwwwwww
w.........A...........w
w.....................w
w.....g........k......w
w.....................w
w.....................w
wwwwwwwwwwwwwwwwwwwwwww`,1:`wwwwwwwwwwwwwwwwwwwwwww
w...A.....w......m....w
w.........w..........kw
w.....g...............w
w.........w...........w
w...m.....w......m....w
wwwwwwwwwwwwwwwwwwwwwww`,2:`wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
w............................w
w...A...........w..1.........w
w...............w.........k..w
wwwwwwwwwwwww1wwwwwwwwwwwwwwww
w............................w
w..m.....w.......w...........w
w...m....w.......w...........w
w.m......w.......w.....g.....w
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww`,3:`wwwwwwwwwwwwwwwwwwwwwww
w.....................w
w...A....k.......m....w
w.............1.......w
w.....................w
w...m.................w
w..............w00wwwww
w....1.m.......w......w
w..............w..g..mw
wwwwwwwwwwwwwwwwwwwwwww`,4:`wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
w............g...............w
w............................w
w........1.....A.............w
w......................1.....w
w............0...............w
wwwwwwwwwwwww0wwwwwwwwwwwwwwww
w.......w..........w.........w
w.......w.......m..w.........w
w.......w..........w.........w
w.......w..........w.........w
w.......w..........w.........w
w.......wwwwwkwwwwww.........w
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww`,5:`wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwg................wwwwww
ww..........................ww
ww.............A............ww
ww...11.................1...ww
ww..........................ww
ww..........................ww
ww..........................ww
wwwwwwwww..........wwwwwwwwwww
w.......w....................w
w.....k00....................w
wwwwwwwww..........wwwwwwwwwww
ww..........................ww
ww..m.......................ww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww`,6:`wwwwwwwwwwwwwwwwwwwwwwwwwwww
w......1..........w........w
w.....1g1.........w........w
w......1..........w........w
w..........................w
w..............1...........w
w.......A......1...........w
w..........................w
w...w0w...........wwwwwwwwww
w...w0w...........w........w
w...wkw...........w........w
w...www...........wwwwwwwwww
w..............m...........w
w..m.......................w
wwwwwwwwwwwwwwwwwwwwwwwwwwww`,7:`wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
w.......w..........wwww.....ww
w.......w..1.......wwww.....ww
wwwwwwwwgm.........00kw..1..ww
ww......w..........wwww.....ww
ww....1.........1...........ww
ww.......A..........1.......ww
ww11111111111111111111111111ww
ww00000000000000000000000000ww
ww00000000000000000000000000ww
ww..........................ww
ww..........................ww
ww............k.............ww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww`,8:`wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwww..........wwwwwwwwwww
wwwwwwwww..........wwwwwwwwwww
wwwwwwwwg...........0kwwwwwwww
wwwwwwwww..........ww0wwwwwwww
ww..........................ww
ww................1.........ww
ww.......A..................ww
wwwwwwwww..........wwwwwwwwwww
wwwwwwwww..........wwwwwwwwwww
ww.........................mww
ww..........................ww
ww......1...................ww
ww..........................ww
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww`,9:`wwwwwwwwwwwwwwwww
w.....wgw.......w
wwwwww...wwwwwwww
w.....w.A.w.....w
w...............w
w..1.........1..w
w...............w
w...............w
wwwwwww.0.wwwwwww
w......w0w......w
w......wkw......w
wwwwwwwwwwwwwwwww`,10:`wwwwwwwwwwwwwwwwwww
w......wwwww......w
w..1...wwwww...1..w
w......00.00......w
w..w.1.00k00.1.w..w
w..w...00000...w..w
w..1...00m00...1..w
w..w...ww1ww...w..w
w.................w
w.................w
w..wwwwww1wwwwww..w
w........Ag.......w
w.................w
wwwwwwwwwwwwwwwwwww`,11:`wwwwwwwwwwwww
w...wkw.....w
w...w000....w
w...w0m01...w
w....0111...w
w.....1A1...w
w....01.1...w
w..1........w
w...........w
w....wwwg...w
wwwwwwwwwwwww`}},bait_vgfmri4:{description:`BasicGame
SpriteSet
floor > Immovable img=colors/LIGHTGRAY
hole > Immovable img=colors/BLUE
avatar > MovingAvatar img=colors/YELLOW
mushroom > Immovable img=colors/BLACK
key > Resource img=colors/ORANGE limit=1
goal > Immovable img=colors/PURPLE
box > Passive img=colors/BROWN
wall > Immovable img=colors/PINK
LevelMapping
. > floor
w > floor wall
A > floor avatar
0 > floor hole
1 > floor box
k > floor key
g > floor goal
m > floor mushroom
InteractionSet
avatar wall > stepBack
avatar hole > killSprite
box avatar > bounceForward
box wall > stepBack
box box > stepBack
box mushroom > undoAll
hole box > killSprite scoreChange=5
box hole > killSprite
avatar key > changeResource resource=key value=5 scoreChange=5
key avatar > killSprite
goal avatar > killIfOtherHasMore resource=key limit=1
mushroom avatar > killSprite scoreChange=10
floor EOS > killSprite
hole EOS > killSprite
avatar EOS > killSprite
mushroom EOS > killSprite
key EOS > killSprite
goal EOS > killSprite
box EOS > killSprite
wall EOS > killSprite
TerminationSet
SpriteCounter stype=goal limit=0 win=True
SpriteCounter stype=avatar limit=0 win=False`,levels:{0:`wwwwwwwwwwwwwwwwwwwww
w.......A...........w
w...................w
w..............k....w
w...................w
w...................w
w...................w
w...................w
w...................w
w..g................w
w...................w
wwwwwwwwwwwwwwwwwwwww`,1:`wwwwwwwwwwwwwwwwwwwww
w...A...m...........w
w...................w
w...............g...w
w...................w
w...................w
w...................w
w...................w
w..m................w
w............k......w
w...................w
wwwwwwwwwwwwwwwwwwwww`,2:`wwwwwwwwwwwwwwwwwwwww
w............w......w
w...A........w.....ww
w............w.....gw
w............w11111ww
w............w......w
w............w......w
w...................w
w...................w
w..k................w
w...................w
wwwwwwwwwwwwwwwwwwwww`,3:`wwwwwwwwwwwwwwwwwwwww
w.........k.........w
w...A.........1.....w
w...................w
w.......1...........w
w...................w
wwwwwwwwww0wwwwwwwwww
w...................w
w...................w
w..g.......mmmmmmm..w
w...................w
wwwwwwwwwwwwwwwwwwwww`,4:`wwwwwwwwwwwwwwwwwwwww
w..............A....w
w............1......w
w.................m.w
w.......g.........m.w
w...1...............w
w...........m.......w
wwwwwwwwwwwwww00wwwww
w...................w
w.............k.....w
w...................w
wwwwwwwwwwwwwwwwwwwww`,5:`wwwwwwwwwwwwwwwwwwwww
w...................w
w...................w
w......1...wwwwwwwwww
w.........m0......g.w
wk........m0........w
w....A....m0........w
w.1....1...wwwwwwwwww
w...................w
w...................w
w...................w
wwwwwwwwwwwwwwwwwwwww`,6:`wwwwwwwwwwwwwwwwwwwww
w.............1.....w
w........1...1g1....w
w.......1.....1.....w
w...A...............w
w........w..........w
w...w0w..w....w0000ww
w...w0w..w....wmmmmww
w...wkw..w....wmmmmww
w...www..w....wmmmmww
w.............wwwwwww
wwwwwwwwwwwwwwwwwwwww`,7:`wwwwwwwwwwwwwwwwwwwww
w..........ww.......w
w..........ww.......w
w.0m....mmmww.......w
wwg0m...w00kw.......w
w.0m....wwwww.......w
w.......1...1.......w
w1...1...A..........w
w..............wwwwww
w..1...........w....w
w..............w..k.w
wwwwwwwwwwwwwwwwwwwww`,8:`wwwwwwwwwww.wwwwwwwww
w.....k...w.......g.w
w.........w.........w
w.........w..1.wwwwww
wwwwww00www....wmmmmw
w.........1....wmmmmw
w.......A......0mmmmw
w....1......wwwwwwwww
w........1..0.......w
w.g.........0....k..w
w.....1.....wwwwwwwww
wwwwwwwwwwwwwwwwwwwww`}},chase_vgfmri3:{description:`BasicGame
SpriteSet
floor > Immovable img=colors/LIGHTGRAY
carcass > Immovable img=colors/BROWN
goat > stype=avatar
angry > Chaser cooldown=8 img=colors/GOLD
scared > Fleeing cooldown=3 img=colors/RED
avatar > MovingAvatar img=colors/DARKBLUE
wall > Immovable img=colors/DARKGRAY
LevelMapping
. > floor
A > floor avatar
0 > floor scared
1 > floor angry
w > floor wall
InteractionSet
angry wall > stepBack
scared wall > stepBack
avatar wall > stepBack
avatar angry > killSprite scoreChange=-1
scared avatar > transformTo stype=carcass scoreChange=1
scared carcass > transformTo stype=angry
carcass angry > killSprite
floor EOS > killSprite
carcass EOS > killSprite
goat EOS > killSprite
angry EOS > killSprite
scared EOS > killSprite
avatar EOS > killSprite
wall EOS > killSprite
TerminationSet
Timeout limit=600 win=False
SpriteCounter stype=scared win=True
SpriteCounter stype=avatar win=False`,levels:{0:`wwwwwwwwwww
w.........w
wA........w
w.........w
w....0....w
w.........w
wwwwwwwwwww`,1:`wwwwwwwwwww
w..0......w
w....w....w
w..www..A.w
w....w....w
w.....0...w
wwwwwwwwwww`,2:`wwwwwwwwwwwwwwwwwwwwwwwww
w.......................w
w.........0.....w.......w
w......wwwwwwwwww.......w
w........w......www.....w
w..........A............w
w.....ww......w....w....w
w.....ww...wwww....w0...w
w.....ww................w
wwww...0..........wwwwwww
w.......................w
wwwwwwwwwwwwwwwwwwwwwwwww`,3:`wwwwwwwwwwwwwwwwwwwwwwwwwww
w...........w.............w
w...w1......w..w...w......w
w......wwwwww..w...w......w
w...w..wwwwww..0...www....w
w...........w......www....w
wwww......0......A........w
w.....ww...wwwwww....w....w
w.....ww...ww.....w..w0...w
w.....w...................w
wwwwwwwwwwwwwwwwwwwwwwwwwww`,4:`wwwwwwwwwwwwwwwwwwwwwwwwwww
w.......0...w.......0.....w
w...w.......w..0..........w
w......wwwwww......w......w
w...w..wwwwww......www....w
w...........w......www....w
wwww.....0.......A........w
w..0..ww...wwwwww....w....w
w.....ww...ww.....w..w0...w
w.....w....0..............w
wwwwwwwwwwwwwwwwwwwwwwwwwww`,5:`wwwwwwwwwwwwwwwwwwwwwwww
wAww..........0..... ..w
w.ww..wwwwww.......www.w
w.ww..... ....ww...w.0.w
w.....w.......ww...w0..w
w..0..w...wwwwww...0...w
w.....w0.....0.... ..www
w.0...wwwwwww.....0....w
w.ww..w..0..w...wwww...w
w.......0.....0........w
wwwwwwwwwwwwwwwwwwwwwwww`,6:`wwwwwwwwwwwwwwwwwwwwwwww
w.....0................w
w..0...w. ....w.0......w
w...w.......0.ww.......w
w.....w........0...w...w
w.0..0.....0w..........w
w.....w....w...w..w....w
w.......w..0....w......w
w...w.....w..0..w..0...w
w......0......A........w
wwwwwwwwwwwwwwwwwwwwwwww`,7:`wwwwwwwwwwwwwwwwwwwwwwww
ww....w......0.....0000w
ww..w.w....w.wwwwwwwww.w
ww..0..ww....... ......w
ww.w...........0.......w
w .......ww.......0....w
w.0.0..ww...0........0.w
w.. .....000...0.0.....w
w......ww..0..0........w
w...A...0......wwwwwww.w
wwwwwwwwwwwwwwwwwwwwwwww`,8:`wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
w....ww....0.................w
w....ww......................w
wA...ww............wwwwww....w
w.........www....0...www.....w
w............................w
wwww....0..............0.....w
w...........wwwwwww..........w
w...1.....................1..w
w..........0...........ww....w
w.....wwwwww...........ww....w
wwww.......w......0....wwwwwww
w......1...w.................w
w..........w.................w
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww`,9:`wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
w.....w......................w
w.....w.....0................w
w.....w............wwwwww....w
w.........www........www.....w
w............................w
wwww..............www........w
w.......0......wwww....A.....w
w.0..........................w
w.....wwwwww...........ww....w
w...0.wwwwww...........ww....w
w..........w...0.......wwwwwww
w..........w.................w
w..........w.................w
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww`,10:`wwwwwwwwwwwwwwwwwwwwwwww
w.0.w..0........w..0...w
w...w....ww.....w..wwwww
w...w.ww..w...0.0......w
w...w.0...w..wwwwwww...w
w.0wwwwwwww..0....w....w
w.............0...w...ww
w.ww...ww0...wwwwww.00.w
wA...wwwwww..0....w....w
www....0......w..0..wwww
wwwwwwwwwwwwwwwwwwwwwwww`,11:`wwwwwwwwwwwwwwwwwwwwwwwwwwwwww
w............................w
w.....w.0..........w.........w
w.....w........0...wwwwww....w
w.....w...www......w.........w
w.....w......................w
wwwwwww....A...wwwwww....0...w
w..............wwwwww........w
w..............0.............w
w........0..........wwwww0...w
w...0.wwwwwww....www...ww....w
w..0.......ww...0w.....wwwwwww
w..........ww................w
w..........ww................w
wwwwwwwwwwwwwwwwwwwwwwwwwwwwww`}},chase_vgfmri4:{description:`BasicGame
SpriteSet
floor > Immovable img=colors/LIGHTGRAY
carcass > Immovable img=colors/BLACK
goat > stype=avatar
angry > Chaser cooldown=8 img=colors/GOLD
scared > Fleeing cooldown=3 img=colors/RED
avatar > MovingAvatar img=colors/DARKBLUE
wall > Immovable img=colors/BROWN
LevelMapping
. > floor
A > floor avatar
0 > floor scared
1 > floor angry
w > floor wall
InteractionSet
angry wall > stepBack
scared wall > stepBack
avatar wall > stepBack
avatar angry > killSprite scoreChange=-1
scared avatar > transformTo stype=carcass scoreChange=1
scared carcass > transformTo stype=angry
carcass angry > killSprite
floor EOS > killSprite
carcass EOS > killSprite
goat EOS > killSprite
angry EOS > killSprite
scared EOS > killSprite
avatar EOS > killSprite
wall EOS > killSprite
TerminationSet
SpriteCounter stype=scared win=True
SpriteCounter stype=avatar win=False`,levels:{0:`wwwwwwwwwwwwwwwwwwwww
w...................w
w...................w
w..............A....w
w...................w
w..........0........w
w...................w
w...................w
w...................w
w...................w
w...................w
wwwwwwwwwwwwwwwwwwwww`,1:`wwwwwwwwwwwwwwwwwwwww
w...................w
w..0................w
w.........w.........w
w.........w.........w
w.........w.........w
w...wwwwwwwwwwww....w
w.........w.........w
w.........w......A..w
w.........w.........w
w.........0.........w
wwwwwwwwwwwwwwwwwwwww`,2:`wwwwwwwwwwwwwwwwwwwww
w...................w
w.....wwwwwwwww.....w
w.....w...0...w.....w
w.....w.......w.....w
w.....w....A..w.....w
w.....w.......w.....w
wwwwwww.......w.....w
w.....w.......w.....w
w.....w.....0.w.....w
wwww..w0......w...www
wwwwwwwwwwwwwwwwwwwww`,3:`wwwwwwwwwwwwwwwwwwwww
w...w0......w.......w
w...w..www..w.......w
w...w..www..w0......w
w...w......0w....0..w
w...w...............w
wwwww0..A...........w
w...................w
w......wwww.0.w.....w
w...0..w...0..w0....w
w......w......w.....w
wwwwwwwwwwwwwwwwwwwww`,4:`wwwwwwwwwwwwwwwwwwwww
w...w...0...........w
w...w...............w
w...w..wwwwww....0..w
w...w..wwwwww.......w
w....0..............w
wwww.........A..wwwww
w.......0...........w
w..1.......wwww.....w
w..........ww..0.0..w
w...........w.......w
wwwwwwwwwwwwwwwwwwwww`,5:`wwwwwwwwwwwwwwwwwwwww
wAwww..........0....w
w...................w
w......w...wwwwwww..w
w..0...w...ww....w..w
w......w0........wwww
w.0....wwwww........w
wwww...w.....w......w
w......w.....w......w
w..1.........w..0...w
w........0...w......w
wwwwwwwwwwwwwwwwwwwww`,6:`wwwwwwwwwwwwwwwwwwwww
w.....0......0.w....w
w..0...wwwwwwwww.0..w
w......w............w
w......w.0..........w
w.0.......A.0www....w
www.....0......wwwwww
w.....w........w....w
w...wwwwwww.0..w....w
w..0w.....w...0...0.w
w...w.....w.........w
wwwwwwwwwwwwwwwwwwwww`,7:`wwwwwwwwwwwwwwwwwwwww
ww...........0..0..0w
wwwwwwww......wwwwwww
ww..1..ww...........w
w.......w...........w
w..........Awwww....w
wwww........w..w..1.w
w.0....www..w.0wwwwww
w...........w..w..0.w
w..............0..0.w
w.......0.........www
wwwwwwwwwwwwwwwwwwwww`,8:`wwwwwwwwwwwwwwwwwwwww
w....ww.............w
w....ww.......wwww..w
w.........0......w..w
wwww....0......0....w
w.........A.........w
w..............wwwwww
w.0..............1..w
w........wwwwww.....w
wwww..........w..0..w
w.........1...w.....w
wwwwwwwwwwwwwwwwwwwww`}},helper_vgfmri3:{description:`BasicGame frame_rate=30
SpriteSet
floor > Immovable img=colors/LIGHTGRAY
avatar > MovingAvatar img=colors/DARKBLUE cooldown=0
mover > VGDLSprite
chaser > Chaser
chaser1 > stype=box1 img=colors/ORANGE cooldown=12
chaser2 > stype=box3 img=colors/LIGHTBLUE cooldown=12
wall > Immovable img=colors/BLACK
forcefield > Passive img=colors/PURPLE
box > Passive
box1 > img=colors/WHITE
box2 > img=colors/GREEN
box3 > img=colors/YELLOW
LevelMapping
. > floor
A > floor avatar
w > floor wall
a > floor box1
b > floor box2
c > floor box3
f > floor forcefield
x > floor chaser1
z > floor chaser2
z > floor chaser2
InteractionSet
avatar wall > stepBack
box wall > stepBack
box3 avatar > bounceForward
box1 avatar > bounceForward
box1 box2 > stepBack
box1 box1 > stepBack
box2 avatar > killSprite
box1 chaser > killSprite
box3 chaser > killSprite
chaser forcefield > stepBack
chaser wall > stepBack
chaser box2 > stepBack
floor EOS > killSprite
avatar EOS > killSprite
mover EOS > killSprite
chaser EOS > killSprite
chaser1 EOS > killSprite
chaser2 EOS > killSprite
wall EOS > killSprite
forcefield EOS > killSprite
box EOS > killSprite
box1 EOS > killSprite
box2 EOS > killSprite
box3 EOS > killSprite
TerminationSet
Timeout limit=600 win=False
SpriteCounter stype=avatar limit=0 win=False
SpriteCounter stype=box1 limit=0 win=True`,levels:{0:`wwwwwwwwwwwwwwwwww
w........a.......w
w......w.........w
w......w.........w
w..x...w......a..w
w......w.........w
w......www.......w
w..A.............w
www...x..........w
wwwwwwwwwwwwwwwwww`,1:`wwwwwwwwwwwwwwwwwwwww
w.x.................w
w...a.....a.........w
w............a......w
w...................w
w...b..........a....w
w........a..........w
w..A..b..........b..w
wwwx................w
wwwwwwwwwwwwwwwwwwwww`,2:`wwwwwwwwwwwwwwwww
w...............w