add bot lag vs AI
This commit is contained in:
parent
7d033e37be
commit
b1c9ab7012
|
@ -13,18 +13,19 @@ import lila.user.User
|
||||||
|
|
||||||
final class BotPlayer(
|
final class BotPlayer(
|
||||||
roundMap: ActorSelection,
|
roundMap: ActorSelection,
|
||||||
chatActor: ActorSelection,
|
chatActor: ActorSelection
|
||||||
system: ActorSystem
|
)(implicit system: ActorSystem) {
|
||||||
) {
|
|
||||||
|
|
||||||
def apply(pov: Pov, me: User, uciStr: String): Funit =
|
def apply(pov: Pov, me: User, uciStr: String): Funit =
|
||||||
Uci(uciStr).fold(fufail[Unit](s"Invalid UCI: $uciStr")) { uci =>
|
lila.common.Future.delay((pov.game.hasAi ?? 500) millis) {
|
||||||
lila.mon.bot.moves(me.username)()
|
Uci(uciStr).fold(fufail[Unit](s"Invalid UCI: $uciStr")) { uci =>
|
||||||
if (!pov.isMyTurn) fufail("Not your turn, or game already over")
|
lila.mon.bot.moves(me.username)()
|
||||||
else {
|
if (!pov.isMyTurn) fufail("Not your turn, or game already over")
|
||||||
val promise = Promise[Unit]
|
else {
|
||||||
roundMap ! Tell(pov.gameId, BotPlay(pov.playerId, uci, promise.some))
|
val promise = Promise[Unit]
|
||||||
promise.future
|
roundMap ! Tell(pov.gameId, BotPlay(pov.playerId, uci, promise.some))
|
||||||
|
promise.future
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,8 @@ final class Env(
|
||||||
|
|
||||||
lazy val player = new BotPlayer(
|
lazy val player = new BotPlayer(
|
||||||
roundMap = hub.actor.roundMap,
|
roundMap = hub.actor.roundMap,
|
||||||
chatActor = hub.actor.chat,
|
chatActor = hub.actor.chat
|
||||||
system = system
|
)(system)
|
||||||
)
|
|
||||||
|
|
||||||
val form = BotForm
|
val form = BotForm
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue