programgames/minesweeper/minesweeper.xtl
p : Int
p ← 0 c̲at₂ (0 c̲at (ᵐm̲ines s) c̲at 0) c̲at₂ 0
Used in: games/minesweeper/minesweeper.xtl:14
ᵘs̲teps : (Num a, Truthy a) => a -> a
Opening a square with no mine around it floods: watch the opened region grow, one ring of neighbors at a time, until it stops.
ᵘs̲teps ← { o → said ← p̲rint! '+ r̲/ r̲avel o more ← 1 × (o ∨ 0 < ᵐa̲round o ∧ 0 = ᵐc̲ounts s) ∧ n̲ot ᵐm̲ines s more m̲atch o ? o ᵘs̲teps more }
ᵘc̲lear : (Num a, Truthy a) => a -> Int -> a
Open every safe square, one after another: the field is cleared.
ᵘc̲lear ← { s v → 0 = t̲ally v ? s next ← s ᵐr̲eveal (1 + ((f̲irst v) − 1) d̲iv 9) c̲at 1 + ((f̲irst v) − 1) m̲od 9 next ᵘc̲lear 1 d̲rop v }