maze.nv
· 4.0 KiB · Text
Raw
Playground
= |pen position| -2 -2 =
= || jump |cells| $row $col =
|matrix position| $row $col
= || jump |generate| =
= || restore cells |discarded cells| $row $col =
|cells| $row $col || restore cells
= || restore cells =
= || delete cell |location| $row $col |cells| $row $col =
|| restore cells
= || delete cell |location| $row $col? |cells| $r $c =
|discarded cells| $r $c
|| delete cell
= || delete cell |location| $row $col =
|| restore cells
= || prepare cells |cells| 127 |@math| 127 =
|cells| 127 127
= || next column |@math| $col =
|cells| 0 $col
|| prepare cells
= || prepare cells |cells| $col |@math| 127 =
|@math|add $col 1
|cells| 127 $col
|| next column
= || prepare cells |cells| $col |@math| $row =
|@math| add $row 1
|cells| $col
|cells| $row $col
|| prepare cells
= || prepare cells |cells| $row $col =
|@math| add $row 1
|cells| $col
|cells| $row $col
|| prepare cells
= || compute down $col |@math| $row =
|down neighbor| $row $col
= || compute right $row |@math| $col =
|right neighbor| $row $col
= || compute up $col |@math| $row =
|up neighbor| $row $col
= || compute left $row |@math| $col =
|left neighbor| $row $col
= || find valid neighbors? |down neighbor| $row $col |cells| $row $col =
|discarded cells| $row $col
|valid down neighbor| $row $col
= || find valid neighbors? |right neighbor| $row $col |cells| $row $col =
|discarded cells| $row $col
|valid right neighbor| $row $col
= || find valid neighbors? |up neighbor| $row $col |cells| $row $col =
|discarded cells| $row $col
|valid up neighbor| $row $col
= || find valid neighbors? |left neighbor| $row $col |cells| $row $col =
|discarded cells| $row $col
|valid left neighbor| $row $col
= || find valid neighbors? |cells| $row $col =
|discarded cells| $row $col
= |up neighbor| $row $col =
= |right neighbor| $row $col =
= |down neighbor| $row $col =
= |left neighbor| $row $col =
= || find valid neighbors =
|| restore cells
= || find neighbors |location| $row $col =
|| compute down $col |@math| add $row 1
|| compute right $row |@math| add $col 1
|| compute up $col |@math| add $row -1
|| compute left $row |@math| add $col -1
|| find valid neighbors
= || go in direction |@math| 1 |valid up neighbor| $row $col =
|| move up || move up
|| delete cell |location| $row $col
|matrix position| $row $col || clear navigation state
= || go in direction |@math| 2 |valid right neighbor| $row $col =
|| move right || move right
|| delete cell |location| $row $col
|matrix position| $row $col || clear navigation state
= || go in direction |@math| 3 |valid down neighbor| $row $col =
|| move down || move down
|| delete cell |location| $row $col
|matrix position| $row $col || clear navigation state
= || go in direction |@math| 4 |valid left neighbor| $row $col =
|| move left || move left
|| delete cell |location| $row $col
|matrix position| $row $col || clear navigation state
= || go in direction? |@math| 1 |sweep|=
|@math| 2
= || go in direction? |@math| 2 |sweep|=
|@math| 3
= || go in direction? |@math| 3 |sweep|=
|@math| 4
= || go in direction? |@math| 4 |sweep|=
|@math| 1
= || go in direction |@math| $n =
|| clear navigation state || jump
= || clear navigation state? |valid up neighbor| $r $c =
= || clear navigation state? |valid left neighbor| $r $c =
= || clear navigation state? |valid down neighbor| $r $c =
= || clear navigation state? |valid right neighbor| $r $c =
= || clear navigation state? |sweep| =
= || clear navigation state =
= || pick a random direction |matrix position| $row $col =
|| find neighbors |location| $row $col
|| go in direction |sweep| |sweep| |sweep|
|@math| random 1 5
= || update |generate|? =
|| pick a random direction
==
|cells| 1 0 |matrix position| 0 0 |screen resolution| 256 256
|| prepare cells
|| pen brush pencil
|| pen down
|| pen color 255 255 255
|generate|
| 1 | = |pen position| -2 -2 = |
| 2 | = || jump |cells| $row $col = |
| 3 | |matrix position| $row $col |
| 4 | = || jump |generate| = |
| 5 | |
| 6 | = || restore cells |discarded cells| $row $col = |
| 7 | |cells| $row $col || restore cells |
| 8 | = || restore cells = |
| 9 | |
| 10 | = || delete cell |location| $row $col |cells| $row $col = |
| 11 | || restore cells |
| 12 | = || delete cell |location| $row $col? |cells| $r $c = |
| 13 | |discarded cells| $r $c |
| 14 | || delete cell |
| 15 | = || delete cell |location| $row $col = |
| 16 | || restore cells |
| 17 | |
| 18 | = || prepare cells |cells| 127 |@math| 127 = |
| 19 | |cells| 127 127 |
| 20 | |
| 21 | = || next column |@math| $col = |
| 22 | |cells| 0 $col |
| 23 | || prepare cells |
| 24 | |
| 25 | = || prepare cells |cells| $col |@math| 127 = |
| 26 | |@math|add $col 1 |
| 27 | |cells| 127 $col |
| 28 | || next column |
| 29 | |
| 30 | = || prepare cells |cells| $col |@math| $row = |
| 31 | |@math| add $row 1 |
| 32 | |cells| $col |
| 33 | |cells| $row $col |
| 34 | || prepare cells |
| 35 | |
| 36 | = || prepare cells |cells| $row $col = |
| 37 | |@math| add $row 1 |
| 38 | |cells| $col |
| 39 | |cells| $row $col |
| 40 | || prepare cells |
| 41 | |
| 42 | = || compute down $col |@math| $row = |
| 43 | |down neighbor| $row $col |
| 44 | |
| 45 | = || compute right $row |@math| $col = |
| 46 | |right neighbor| $row $col |
| 47 | |
| 48 | = || compute up $col |@math| $row = |
| 49 | |up neighbor| $row $col |
| 50 | |
| 51 | = || compute left $row |@math| $col = |
| 52 | |left neighbor| $row $col |
| 53 | |
| 54 | = || find valid neighbors? |down neighbor| $row $col |cells| $row $col = |
| 55 | |discarded cells| $row $col |
| 56 | |valid down neighbor| $row $col |
| 57 | |
| 58 | = || find valid neighbors? |right neighbor| $row $col |cells| $row $col = |
| 59 | |discarded cells| $row $col |
| 60 | |valid right neighbor| $row $col |
| 61 | |
| 62 | = || find valid neighbors? |up neighbor| $row $col |cells| $row $col = |
| 63 | |discarded cells| $row $col |
| 64 | |valid up neighbor| $row $col |
| 65 | |
| 66 | = || find valid neighbors? |left neighbor| $row $col |cells| $row $col = |
| 67 | |discarded cells| $row $col |
| 68 | |valid left neighbor| $row $col |
| 69 | |
| 70 | = || find valid neighbors? |cells| $row $col = |
| 71 | |discarded cells| $row $col |
| 72 | |
| 73 | = |up neighbor| $row $col = |
| 74 | = |right neighbor| $row $col = |
| 75 | = |down neighbor| $row $col = |
| 76 | = |left neighbor| $row $col = |
| 77 | |
| 78 | = || find valid neighbors = |
| 79 | || restore cells |
| 80 | |
| 81 | = || find neighbors |location| $row $col = |
| 82 | || compute down $col |@math| add $row 1 |
| 83 | || compute right $row |@math| add $col 1 |
| 84 | || compute up $col |@math| add $row -1 |
| 85 | || compute left $row |@math| add $col -1 |
| 86 | || find valid neighbors |
| 87 | |
| 88 | = || go in direction |@math| 1 |valid up neighbor| $row $col = |
| 89 | || move up || move up |
| 90 | || delete cell |location| $row $col |
| 91 | |matrix position| $row $col || clear navigation state |
| 92 | |
| 93 | = || go in direction |@math| 2 |valid right neighbor| $row $col = |
| 94 | || move right || move right |
| 95 | || delete cell |location| $row $col |
| 96 | |matrix position| $row $col || clear navigation state |
| 97 | |
| 98 | = || go in direction |@math| 3 |valid down neighbor| $row $col = |
| 99 | || move down || move down |
| 100 | || delete cell |location| $row $col |
| 101 | |matrix position| $row $col || clear navigation state |
| 102 | |
| 103 | = || go in direction |@math| 4 |valid left neighbor| $row $col = |
| 104 | || move left || move left |
| 105 | || delete cell |location| $row $col |
| 106 | |matrix position| $row $col || clear navigation state |
| 107 | |
| 108 | = || go in direction? |@math| 1 |sweep|= |
| 109 | |@math| 2 |
| 110 | = || go in direction? |@math| 2 |sweep|= |
| 111 | |@math| 3 |
| 112 | = || go in direction? |@math| 3 |sweep|= |
| 113 | |@math| 4 |
| 114 | = || go in direction? |@math| 4 |sweep|= |
| 115 | |@math| 1 |
| 116 | |
| 117 | = || go in direction |@math| $n = |
| 118 | || clear navigation state || jump |
| 119 | |
| 120 | = || clear navigation state? |valid up neighbor| $r $c = |
| 121 | = || clear navigation state? |valid left neighbor| $r $c = |
| 122 | = || clear navigation state? |valid down neighbor| $r $c = |
| 123 | = || clear navigation state? |valid right neighbor| $r $c = |
| 124 | = || clear navigation state? |sweep| = |
| 125 | = || clear navigation state = |
| 126 | |
| 127 | = || pick a random direction |matrix position| $row $col = |
| 128 | || find neighbors |location| $row $col |
| 129 | || go in direction |sweep| |sweep| |sweep| |
| 130 | |@math| random 1 5 |
| 131 | |
| 132 | = || update |generate|? = |
| 133 | || pick a random direction |
| 134 | |
| 135 | == |
| 136 | |cells| 1 0 |matrix position| 0 0 |screen resolution| 256 256 |
| 137 | || prepare cells |
| 138 | || pen brush pencil |
| 139 | || pen down |
| 140 | || pen color 255 255 255 |
| 141 | |generate| |
| 142 | |
| 143 |