|
|
|
@ -7,6 +7,21 @@
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
public struct TicTacToeRules: Rules {
|
|
|
|
|
|
|
|
|
|
func possibleMoves(board: Board) -> [(row: Int, column: Int)] {
|
|
|
|
|
var possibleMoves: [(Int, Int)] = []
|
|
|
|
|
|
|
|
|
|
for column in 0..<board.columnNb {
|
|
|
|
|
for row in 0..<board.rowNb {
|
|
|
|
|
if board[row, column] == Token.empty {
|
|
|
|
|
possibleMoves.append((row, column)) // Ajouter la position (row, column)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return possibleMoves
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func add(board: inout Board, position pos: (row: Int, column: Int), token: Token) -> Bool {
|
|
|
|
|
if board[pos.0, pos.1] == .empty {
|
|
|
|
|
board[pos.0, pos.1] = token
|
|
|
|
@ -20,4 +35,5 @@ public struct TicTacToeRules: Rules {
|
|
|
|
|
// TODO
|
|
|
|
|
return (false, Token.empty)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|