Last active 1 month ago Unlisted

gistfile1.txt Raw Playground
1||:@include: lib/rpn.nv
2
3|:rewind: yes? :playfield: ___ | :behind: ___
4 :: increment playfield size
5
6|:comment: if theres a dot in front of pac eat it |
7|:rewind: yes? :playfield: (pacman dot) |
8 :behind: ___
9 :: increment playfield size
10 :playfield: pacman
11
12|:comment: if theres a ghost in front of pac eat it |
13|:rewind: yes? :playfield: (pacman ghost) |
14 :behind: ___
15 :: increment playfield size
16 :playfield: pacman
17
18|:comment: if pac hits a wall set the done flag |
19|:rewind: yes? :playfield: (pacman wall) | :status: done
20 :ahead: (wall pacman)
21 :: increment playfield size
22 :: increment playfield size
23
24|:comment: otherwise move everything to the tracking tapes |
25|:rewind: yes? :playfield: pacman | :ahead: pacman
26 :: increment playfield size
27|:rewind: yes? :playfield: dot | :ahead: dot
28 :: increment playfield size
29|:rewind: yes? :playfield: dot | :ahead: ghost
30 :: increment playfield size
31|:rewind: yes :playfield: wall | :ahead: wall
32 :: increment playfield size
33
34|:comment: use RPN for counting |
35|:: increment playfield size :@rpn data: $id |
36 :playfield size: $id
37|:: increment playfield size? :playfield size: $id |
38 :@rpn: ($id 1 +)
39
40|:comment: make a note of how long the playfield was |
41|:: :ahead: wall? :playfield size: $limit |
42 :layout: ahead
43 :full run: $limit
44
45|:comment: restore the playfield from the tapes |
46|:layout: ahead :ahead: pacman | :playfield: pacman
47 :layout: behind
48 :: decrement playfield size
49|:layout: ahead? :ahead: $a | :playfield: $a
50 :: decrement playfield size
51|:layout: behind? :behind: $b | :playfield: $b
52 :: decrement playfield size
53
54|:full run: $x |:playfield size: $x
55|:: decrement playfield size :@rpn data: $id |
56 :playfield size: $id
57|:: decrement playfield size? :playfield size: $id |
58 :@rpn: ($id 1 -)
59
60|:comment: check if the frame is done and if the run is done |
61|:playfield size: 0? :layout: $x :status: done | :rewind: no
62|:playfield size: 0? :layout: $x | :rewind: yes
63
64|| :playfield: (___ ___ pacman dot dot dot ghost dot wall)
65|| :playfield size: 0
66|| :rewind: yes