programgames/robot-chase/play.xtl
ᵘa̲sk : Any a => a -> Int
A command: the first number on the line; one that is not a command is asked for again.
ᵘa̲sk ← { s → said ← p̲rint! "" said ← p̲rint! "1-9=MOVE(5=WAIT) 0=TELE 10=LRS 99=QUIT" c ← ᵖn̲umber "COMMAND ?" (c m̲ember? 0 1 2 3 4 5 6 7 8 9 10 99) ? c◆ ᵘa̲sk s }
ᵘs̲how : Int -> Char
The board and its header, as the BASIC prints them each turn.
ᵘs̲how ← { s → said ← p̲rint! "" pic ← ⎕S̲HOW ʳp̲icture s said ← p̲rint! @ f̲ormat< "TURN {r:t_urn s} ROBOTS {'+ r_/ r:a_live s} TELE {r:t_ele s}" ʳv̲iew s }
ᵘt̲urn : Int -> Char
A turn: show, read, move (or scan), say what happened, until the end.
ᵘt̲urn ← { s → shown ← p̲rint! ᵘs̲how s c ← ᵘa̲sk s c = 10 ? ᵘt̲urn ᵘs̲can s t ← s ʳm̲ove c 0 = ʳe̲vent t ? ᵘa̲fter t◆ ᵘa̲fter ᵘs̲ay t }
ᵘs̲can : Int -> Int
ᵘs̲can ← { s → said ← p̲rint! "" said ← p̲rint! "LRS: ROBOTS, WRECKS, YOU IN EACH 4X4 REGION" shown ← p̲rint! ʳl̲rs s s }
Used in: ᵘt̲urn