module Logic.Square;

open import Stdlib.Prelude;
open import Logic.Symbol;
open import Stdlib.Data.Nat.Ord;
open import Logic.Extra;

--- A square is each of the holes in a board
type Square :=
  | --- An empty square has a ;Nat; that uniquely identifies it
    empty : NatSquare
  | --- An occupied square has a ;Symbol; in it
    occupied : SymbolSquare;

--- Equality for ;Square;s
==Square : SquareSquareBool;
==Square (empty m) (empty n) := m == n;
==Square (occupied s) (occupied t) := ==Symbol s t;
==Square _ _ := false;

--- Textual representation of a ;Square;
showSquare : SquareString;
showSquare (empty n) := " " ++str natToString n ++str " ";
showSquare (occupied s) := " " ++str showSymbol s ++str " ";

replace : SymbolNatSquareSquare;
replace player k (empty n) :=
  if (n Stdlib.Data.Nat.Ord.== k) (occupied player) (empty n);
replace _ _ s := s;
Last modified on 2023-05-08 11:40 UTC