sourcegames/lights-out/play.xtl
1⍝!/usr/bin/env xetal
2⍝# Lights out: a 5 by 5 board you click. A press toggles a light and its
3⍝# four neighbors; turn every light off. New puzzle starts another (every
4⍝# one can be solved), Hint rings a square of a solution X_eTaL works out
5⍝# over GF(2). On the page the board is in a dialog and your clicks come
6⍝# to the program as events; at the command line, lines such as
7⍝# "click 285 215" on standard input. The rules, the solver and the
8⍝# drawing are Lamps.xtl's.
9ˡᵒ⁼u̲se< "Lamps"
10
11⍝# Show the board, read the next event, act on a click, again.
12ᵘl̲oop ← { s →
13 said ← p̲rint! ˡᵒs̲ay s
14 pic ← ⎕S̲HOW ˡᵒd̲raw s
15 e ← ⎕E̲VENT @
16 "end" m̲atch ⎕E̲KIND e ? "THE END"
17 "click" m̲atch ⎕E̲KIND e ? ᵘl̲oop s ˡᵒc̲lick ⎕E̲AT e◆ ᵘl̲oop s
18}
19ᵘl̲oop ˡᵒn̲ew 0