programgames/horse-race/play.xtl
ᵘr̲ace : Int -> Int
The race, a round at a time, the track printed after each round.
ᵘr̲ace ← { p → q ← p ʰʳm̲ove ʰʳr̲oll p shown ← p̲rint! ʰʳv̲iew q gap ← p̲rint! "" 1 = ʰʳs̲tatus q ? q◆ ᵘr̲ace q }
ᵘa̲sk : a -> Int
Your pick: 1 to 5, 0 to stop, or it asks again.
ᵘa̲sk ← { c → k ← (@ f̲ormat< "you have {c} coins; your horse (1 to 5, q to stop):") ᵖl̲etter "12345q" k ≤ 5 ? k◆ k = 6 ? 0◆ ᵘa̲sk c }
ᵘb̲et : Int -> Char
One race on your pick, then the next, until you stop or run out.
ᵘb̲et ← { c → k ← ᵘa̲sk c k = 0 ? @ f̲ormat< "you leave with {c}" shown ← p̲rint! @ f̲ormat< "THE RACE IS ON! you are on {k s_elect hr:n_ames @}" w ← ʰʳw̲inners ᵘr̲ace ʰʳn̲ew 5 won ← f̲irst k m̲ember? w said ← p̲rint! @ f̲ormat< "WINNER: {r_avel w s_elect hr:n_ames @}" c ← c + (4 × won) − 1 told ← p̲rint! d̲isclose (1 + won) s̲elect "you lose a coin" "you win 4 coins" c = 0 ? "out of coins"◆ ᵘb̲et c }
Used in: ᵘb̲et, games/horse-race/play.xtl:35