parent
b9853390ed
commit
f1fab2ec5a
@ -0,0 +1,3 @@
|
||||
public class AIPlayer : Player {
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
public typealias MoveCallback = ([Move.Action], Board) -> Move.Action
|
||||
|
||||
public class HumanPlayer : Player {
|
||||
private let callback: MoveCallback
|
||||
|
||||
public init(name: String, callback: @escaping MoveCallback) {
|
||||
self.callback = callback
|
||||
|
||||
super.init(name: name)
|
||||
}
|
||||
|
||||
public override func chooseMove(allowed_moves moves: [Move.Action], board: Board) -> Move.Action {
|
||||
callback(moves, board)
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
public class Player {
|
||||
public let name: String
|
||||
|
||||
init(name: String) {
|
||||
self.name = name
|
||||
}
|
||||
|
||||
public func chooseMove(allowed_moves moves: [Move.Action], board: Board) -> Move.Action {
|
||||
fatalError("abstract method not implemented")
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
public class RandomPlayer : Player {
|
||||
public override func chooseMove(allowed_moves moves: [Move.Action], board: Board) -> Move.Action {
|
||||
moves[Int.random(in: moves.indices)]
|
||||
}
|
||||
}
|
Loading…
Reference in new issue