programgames/shut-the-box/play.xtl
ᵘa̲sk : Truthy a => a -> a
The tiles typed, as a 0/1 vector of 9, if they are one of the moves; else it asks again.
ᵘa̲sk ← { m → want ← (r̲ange 9) m̲ember? ᵖn̲umbers "TILES TO SHUT ?" '∨ r̲/ '∧ r̲/₂ m = ((t̲ally m) c̲at 9) r̲eshape want ? want◆ ᵘa̲sk m }
ᵘt̲urn : Int -> Char
A turn: the box, the roll, the moves; shut, until stuck or shut.
ᵘt̲urn ← { s → said ← p̲rint! "" said ← p̲rint! ᵇv̲iew s d ← ᵇr̲oll s r ← '+ r̲/ d said ← p̲rint! @ f̲ormat< "YOU ROLL {d}: {r}" m ← s ᵇm̲oves r 0 = t̲ally m ? @ f̲ormat< "NO MOVE. YOUR SCORE: {b:s_core s}" said ← p̲rint! "MOVES:" listed ← ˣl̲ines ᵇl̲isted m t ← s ᵇs̲hut ᵘa̲sk m 0 = ᵇs̲core t ? "YOU SHUT THE BOX!" ᵘt̲urn t }
Used in: ᵘt̲urn, games/shut-the-box/play.xtl:33