lazy AI backend resolution
This commit is contained in:
parent
8e534c7c9a
commit
9b0364fd68
|
@ -22,7 +22,7 @@ final class Env(
|
|||
}
|
||||
import settings._
|
||||
|
||||
lazy val ai: Ai = (EngineName, IsClient) match {
|
||||
val ai: () ⇒ Ai = () ⇒ (EngineName, IsClient) match {
|
||||
case ("stockfish", true) ⇒ stockfishClient or stockfishAi
|
||||
case ("stockfish", false) ⇒ stockfishAi
|
||||
case _ ⇒ stupidAi
|
||||
|
@ -39,7 +39,7 @@ final class Env(
|
|||
def receive = {
|
||||
case lila.hub.actorApi.ai.Ping ⇒ sender ! clientPing
|
||||
case lila.hub.actorApi.ai.Analyse(id, pgn, fen) ⇒
|
||||
ai.analyse(pgn, fen) map { _(id) } pipeTo sender
|
||||
ai().analyse(pgn, fen) map { _(id) } pipeTo sender
|
||||
}
|
||||
}), name = ActorName)
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ final class Env(
|
|||
flood: lila.security.Flood,
|
||||
db: lila.db.Env,
|
||||
hub: lila.hub.Env,
|
||||
ai: lila.ai.Ai,
|
||||
ai: () ⇒ lila.ai.Ai,
|
||||
getUsername: String ⇒ Fu[Option[String]],
|
||||
i18nKeys: lila.i18n.I18nKeys,
|
||||
scheduler: lila.common.Scheduler) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import lila.game.{ Game, GameRepo, PgnRepo, Pov, Progress }
|
|||
import lila.hub.actorApi.Tell
|
||||
|
||||
private[round] final class Player(
|
||||
ai: Ai,
|
||||
ai: () ⇒ Ai,
|
||||
notifyMove: (String, String, Option[String]) ⇒ Unit,
|
||||
finisher: Finisher,
|
||||
roundMap: lila.hub.ActorLazyRef) {
|
||||
|
@ -46,7 +46,7 @@ private[round] final class Player(
|
|||
(game.variant.exotic ?? { GameRepo initialFen game.id }) zip
|
||||
(PgnRepo get game.id) flatMap {
|
||||
case (fen, pgn) ⇒
|
||||
ai.play(game.toChess, pgn, fen, ~game.aiLevel) flatMap {
|
||||
ai().play(game.toChess, pgn, fen, ~game.aiLevel) flatMap {
|
||||
case (newChessGame, move) ⇒ {
|
||||
val (progress, pgn2) = game.update(newChessGame, move)
|
||||
(GameRepo save progress) >>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila.setup
|
||||
|
||||
import akka.actor._
|
||||
import com.typesafe.config.{ Config => AppConfig }
|
||||
import com.typesafe.config.{ Config ⇒ AppConfig }
|
||||
|
||||
import lila.common.PimpedConfig._
|
||||
import lila.user.Context
|
||||
|
@ -11,7 +11,7 @@ final class Env(
|
|||
db: lila.db.Env,
|
||||
hub: lila.hub.Env,
|
||||
messenger: lila.round.Messenger,
|
||||
ai: lila.ai.Ai,
|
||||
ai: () ⇒ lila.ai.Ai,
|
||||
system: ActorSystem) {
|
||||
|
||||
private val FriendMemoTtl = config duration "friend.memo.ttl"
|
||||
|
@ -28,7 +28,7 @@ final class Env(
|
|||
friendConfigMemo = friendConfigMemo,
|
||||
timeline = hub.actor.gameTimeline,
|
||||
router = hub.actor.router,
|
||||
ai = ai)
|
||||
getAi = ai)
|
||||
|
||||
lazy val friendJoiner = new FriendJoiner(
|
||||
messenger = messenger,
|
||||
|
|
|
@ -21,7 +21,7 @@ private[setup] final class Processor(
|
|||
friendConfigMemo: FriendConfigMemo,
|
||||
timeline: lila.hub.ActorLazyRef,
|
||||
router: lila.hub.ActorLazyRef,
|
||||
ai: Ai) {
|
||||
getAi: () ⇒ Ai) {
|
||||
|
||||
def filter(config: FilterConfig)(implicit ctx: Context): Funit =
|
||||
saveConfig(_ withFilter config)
|
||||
|
@ -35,7 +35,7 @@ private[setup] final class Processor(
|
|||
game.player.isHuman.fold(fuccess(pov), for {
|
||||
initialFen ← game.variant.exotic ?? (GameRepo initialFen game.id)
|
||||
pgnString ← PgnRepo get game.id
|
||||
aiResult ← ai.play(game.toChess, pgnString, initialFen, ~game.aiLevel)
|
||||
aiResult ← getAi().play(game.toChess, pgnString, initialFen, ~game.aiLevel)
|
||||
(newChessGame, move) = aiResult
|
||||
(progress, pgn) = game.update(newChessGame, move)
|
||||
_ ← (GameRepo save progress) >> PgnRepo.save(game.id, pgn)
|
||||
|
|
Loading…
Reference in a new issue