def know_hidden.go
minebender-game@1.0.0.0 · proof_grid.bend:133
import minebender-game@1.0.0.0/proof_grid.bend as ProofGrid
import Base
import minebender-game@1.0.0.0/types.bend as T
import minebender-game@1.0.0.0/board.bend as B
import minebender-game@1.0.0.0/game.bend as G
import minebender-game@1.0.0.0/LAWS.bend as L
133def know_hidden.go(+w: Nat, +h: Nat, +layout: T.Grid(Bool), +shown: T.Grid(Bool),
134 +x: Nat, +y: Nat, +b: Bool, +e: {B.on_board(w, h, T.Pos{x, y}) == b : Bool}) ->
135 {Bool.and(B.on_board(w, h, T.Pos{x, y}),
136 L.is_hidden(L.at(T.Seen, T.Hidden{}, G.know_rows(w, h, layout, shown, List.range(h)), T.Pos{x, y})))
137 == Bool.and(B.on_board(w, h, T.Pos{x, y}), Bool.not(B.at(Bool, False{}, shown, T.Pos{x, y})))
138 : Bool}:
139 match b:
140 case False{}:
141 %Equal.sym(Bool, B.on_board(w, h, T.Pos{x, y}), False{}, e) :
142 {Bool.and(_, L.is_hidden(L.at(T.Seen, T.Hidden{}, G.know_rows(w, h, layout, shown, List.range(h)), T.Pos{x, y})))
143 == Bool.and(_, Bool.not(B.at(Bool, False{}, shown, T.Pos{x, y}))) : Bool}
144 {==}
145 case True{}:
146 +rows = G.know_rows(w, h, layout, shown, List.range(h))
147 +p = {T.Pos{x, y} : T.Pos}
148 %Equal.sym(Bool, B.on_board(w, h, p), True{}, e) :
149 {Bool.and(_, L.is_hidden(L.at(T.Seen, T.Hidden{}, rows, p)))
150 == Bool.and(_, Bool.not(B.at(Bool, False{}, shown, p))) : Bool}
151 %Equal.sym(T.Seen, L.at(T.Seen, T.Hidden{}, rows, p), G.seen_at(w, h, layout, shown, p),
152 know_at(w, h, layout, shown, x, y, e)) :
153 {L.is_hidden(_) == Bool.not(B.at(Bool, False{}, shown, p)) : Bool}
154 hidden_pick(B.at(Bool, False{}, shown, p), B.mine(layout, p), w, h, layout, p)