Skip to content

The example games

tilttek/mini-games

Two traditional games of pencil and paper, free of rights, written as models of a mini-game.

Bulls and Cows

Game\BullsAndCows, named bulls-and-cows: find a code of different digits. Each guess tells how many of its digits are in the right place — the bulls — and how many are in the code at another place — the cows.

PartWhat it is
Optionslength, the digits of the code: 4, from 3 to 5; attempts, the guesses allowed: 10, from 6 to 12
Movebulls-and-cows.guess, {guess: "0472"}: as many different digits as the code; anything else is refused with IllegalMove
OutcomeThe code found wins, with the guesses taken as score; running out of guesses ends the game with no score
ScoringScoreOrder::LowerIsBetter
Controlsdigit on 0 to 9, erase on Backspace, guess on Enter
ViewThe length, each guess with its bulls and cows, the guesses left, and the code once the game is over
ShareOne row per guess, bulls then cows then misses; taken/attempts, - while the game goes on, X when the code was not found

Game\Code reads a guess — Code::read('0472', 4) — and scores it against the code: [bulls, cows].

Higher or Lower

Game\HigherOrLower, named higher-or-lower: a number from 1 to 100 is shown; call whether the next is higher or lower, ten times in a row. The eleven numbers are all different.

PartWhat it is
Movehigher-or-lower.call, {call: "higher"} or {call: "lower"}
OutcomeTen right calls win; a wrong call ends the game. Either way, the right calls are reported as score
ScoringScoreOrder::HigherIsBetter
Controlshigher on ArrowUp and h, lower on ArrowDown and l
ViewThe numbers shown so far — never the next —, whether each call was right, and the calls left
ShareOne row of ten cells: right, wrong, then not played; right/10