Skip to content

Commit

Permalink
fix game from position analysis charts and evals
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jun 8, 2015
1 parent dbd8c9b commit 8aeccab
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion modules/ai/src/main/Queue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private[ai] final class Queue(config: Config) extends Actor {
case FullAnalReq(moves, fen, requestedByHuman, variant) if (requestedByHuman || tasks.size < maxTasks) =>
val mrSender = sender
val size = moves.size
val startedAtPly = fen.flatMap(chess.format.Forsyth.getPly)
implicit val timeout = makeTimeout {
if (requestedByHuman) 1.hour else 24.hours
}
Expand All @@ -70,7 +71,7 @@ private[ai] final class Queue(config: Config) extends Actor {
Future.fold(futures)(Vector[Option[Evaluation]]())(_ :+ _) addFailureEffect {
case e => mrSender ! Status.Failure(e)
} foreach { results =>
mrSender ! Evaluation.toInfos(results.toList.map(_ | Evaluation.empty), moves)
mrSender ! Evaluation.toInfos(results.toList.map(_ | Evaluation.empty), moves, ~startedAtPly)
}

case r: FullAnalReq =>
Expand Down
4 changes: 2 additions & 2 deletions modules/analyse/src/main/Evaluation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object Evaluation {
val start = Evaluation(Score(30).some, none, Nil)
val empty = Evaluation(none, none, Nil)

def toInfos(evals: List[Evaluation], moves: List[String]): List[Info] =
def toInfos(evals: List[Evaluation], moves: List[String], startedAtPly: Int): List[Info] =
(evals filterNot (_.checkMate) sliding 2).toList.zip(moves).zipWithIndex map {
case ((List(before, after), move), index) => {
val variation = before.line match {
Expand All @@ -28,7 +28,7 @@ object Evaluation {
}
val best = variation.headOption flatMap UciMove.apply
Info(
ply = index + 1,
ply = index + 1 + startedAtPly,
score = after.score,
mate = after.mate,
variation = variation,
Expand Down
2 changes: 1 addition & 1 deletion modules/chess
Submodule chess updated from afcafc to f4b12e
4 changes: 2 additions & 2 deletions public/javascripts/big.js
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ lichess.storage = {
if (chart) {
if (path.length > 1) unselect(chart);
else {
point = chart.series[0].data[path[0].ply - 1];
point = chart.series[0].data[path[0].ply - 1 - cfg.data.game.startedAtTurn];
if (typeof point != "undefined") point.select();
else unselect(chart);
}
Expand All @@ -2085,7 +2085,7 @@ lichess.storage = {
else {
var white = path[0].ply % 2 !== 0;
var serie = white ? 0 : 1;
var turn = Math.floor((path[0].ply - 1) / 2);
var turn = Math.floor((path[0].ply - 1 - cfg.data.game.startedAtTurn) / 2);
point = chart.series[serie].data[turn];
if (typeof point != "undefined") point.select();
else unselect(chart);
Expand Down

0 comments on commit 8aeccab

Please sign in to comment.