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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
Connect4/Model/Sources/Model/Players/Player.swift

30 lines
876 B

public class Player : Equatable {
public let name: String
public let piece_type: PieceType
public var type: PlayerType { fatalError("abstract property not implemented") }
public init(name: String, piece_type: PieceType) {
self.name = name
self.piece_type = piece_type
}
public func chooseMove(allowed_moves moves: [Move.Action], board: Board) async -> Move.Action {
fatalError("abstract method not implemented")
}
/// Called when there is no possible move for this player's turn
public func skipMove(board: Board) -> Void {
// NO-OP
}
public static func == (lhs: Player, rhs: Player) -> Bool {
lhs === rhs || (lhs.type == rhs.type && lhs.name == rhs.name && lhs.piece_type == rhs.piece_type)
}
}
public enum PlayerType: CaseIterable {
case Human
case AIRandom
}