1 import Base 2 3 # The interface between the game and its laws. LAWS.bend talks about the game 4 # only through these types and the accessors in game.bend. 5 6 # A grid is a list of rows. A layout is a grid of Bool, True where a mine is. 7 def Grid(-A: Data) -> Data: 8 List<&2, List<&2, A>> 9 10 # A cell: column x, row y; Pos{0n, 0n} is the top-left cell. 11 type Pos is Data: 12 Pos{x: Nat, y: Nat} 13 14 # What the player sees in one cell. Flags are not here: they are the player's 15 # beliefs, not knowledge. 16 type Seen is Data: 17 Hidden{} 18 Shown{n: Nat} 19 Boom{} 20 21 # Everything the player knows: the board is w columns by h rows, it holds 22 # `mines` mines in total, and `rows` holds one Seen per cell, row by row. 23 type Knowledge is Data: 24 Knowledge{w: Nat, h: Nat, mines: Nat, rows: Grid(Seen)} 25 26 # What the player can do. The assist carries a random number, which picks 27 # the cell it opens when the player is stuck. 28 type Action is Data: 29 Reveal{p: Pos} 30 Chord{p: Pos} 31 Flag{p: Pos} 32 Assist{k: Nat} 33 34 # Why a game was lost: the player revealed the mine at p, or pressed the assist 35 # while `safe` could have been revealed without guessing. 36 type Loss is Data: 37 Exploded{p: Pos} 38 AssistTooEarly{safe: Pos} 39 40 type Status is Data: 41 Playing{} 42 Won{} 43 Lost{why: Loss} 44 45 # A board size and mine count, as in Windows XP's Game menu. 46 type Level is Data: 47 Beginner{} 48 Intermediate{} 49 Expert{} 50 Custom{w: Nat, h: Nat, mines: Nat} 51 52 type Setup is Data: 53 Setup{w: Nat, h: Nat, mines: Nat} 54 55 # What one cell looks like on screen. 56 type Tile is Data: 57 Covered{} 58 Flagged{} 59 Number{n: Nat} 60 Blast{} 61 Mine{} 62 BadFlag{} 63 Hint{}