sourcegames/maze/maze.xtl

1⍝!/usr/bin/env xetal 2⍝│ The maze, scripted (seed 1), with the rules of Walls.xtl: a maze carved 3⍝│ with whole-array operations, the way out found by a flood, and the 4⍝│ view ahead looked up at every depth at once. 5"mz:" u̲se< "Walls" 6 7⍝ A new maze (seed 1), 8 cells by 8 in maze.toml: 17 blocks by 17, 1 a 8⍝ wall, 0 open. Carved row by row in one go: each cell joins its east 9⍝ neighbor at random, cutting each row into runs, and each run below the 10⍝ top opens north from one cell picked at random. 11s ← ᵐᶻn̲ew 0 12ᵐᶻg̲rid s 13 14⍝ Every open block's distance from you (bottom left), by a flood: each 15⍝ block one more than its nearest neighbor, all at once, until nothing 16⍝ changes. The way out is put at the farthest. 17ᵐᶻd̲istances s 18 19⍝ The steps taken, which way you face (0 north), your block, the way 20⍝ out's block. 21ᵐᶻy̲ou s 22 23⍝ A few keys: the mini map on, then up the left side and turn right. 24ᵘp̲ress ← { s k → s ᵐᶻk̲ey k } 25walked ← (((s ᵘp̲ress "m") ᵘp̲ress "UP") ᵘp̲ress "UP") ᵘp̲ress "RIGHT" 26ᵐᶻy̲ou walked 27 28⍝ The blocks seen so far: what has been in view. 29ᵐᶻs̲een walked 30_ ← ⎕S̲HOW ᵐᶻd̲raw walked 31 32⍝ What the maze guarantees, checked by a_ssert< (silent when it holds). 33t ← ᵐᶻn̲ew 0 34_ ← "'& r_/ (0 <= r_avel mz:d_istances t) = r_avel 0 = mz:g_rid t" a̲ssert< "every open block can be reached"
a̲ssert< expands to
({ @ → ('∧ r̲/ (0 ≤ r̲avel ᵐᶻd̲istances t) = r̲avel 0 = ᵐᶻg̲rid t) ? @◆ ⎕E̲RR "assertion failed: '& r_/ (0 <= r_avel mz:d_istances t) = r_avel 0 = mz:g_rid t (every open block can be reached) [games/maze/maze.xtl:34]"◆ @ } @)
35_ ← "0 = mz:s_tatus walked" a̲ssert< "still looking"
a̲ssert< expands to
({ @ → (0 = ᵐᶻs̲tatus walked) ? @◆ ⎕E̲RR "assertion failed: 0 = mz:s_tatus walked (still looking) [games/maze/maze.xtl:35]"◆ @ } @)