You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
634 B
28 lines
634 B
public protocol Rules {
|
|
// var state: GameState { get }
|
|
|
|
// var history: [Move] { get }
|
|
|
|
func createBoard() -> Board
|
|
|
|
func isValid(board: Board) -> Bool
|
|
|
|
func isValid(board: Board, move: Move) -> Bool
|
|
|
|
func validMoves(board: Board) -> [Move]
|
|
|
|
func validMoves(board: Board, for_player player: Player) -> [Move.Action]
|
|
|
|
func gameState(board: Board, last_turn: Player?) -> GameState
|
|
|
|
// mutating func onMoveDone(move: Move, board: Board) -> Void
|
|
}
|
|
|
|
public enum GameState: Equatable {
|
|
case Playing(turn: Player)
|
|
|
|
case Win(winner: Player, board: Board, cells: [Coords])
|
|
|
|
case Draw
|
|
}
|