my $info = $engine->{'info'};
+ # Search for "multipv" first of all, since e.g. Stockfish doesn't put it first.
+ for my $i (0..$#x - 1) {
+ if ($x[$i] =~ 'multipv') {
+ $mpv = $x[$i + 1];
+ next;
+ }
+ }
+
while (scalar @x > 0) {
if ($x[0] =~ 'multipv') {
+ # Dealt with above
+ shift @x;
shift @x;
- $mpv = shift @x;
next;
}
if ($x[0] =~ /^(currmove|currmovenumber|cpuload)$/) {
$text .= sprintf " %u nodes, %7u nodes/sec, depth %u ply",
$info->{'nodes'}, $info->{'nps'}, $info->{'depth'};
}
+ if (exists($info->{'seldepth'})) {
+ $text .= sprintf " (%u selective)", $info->{'seldepth'};
+ }
if (exists($info->{'tbhits'}) && $info->{'tbhits'} > 0) {
if ($info->{'tbhits'} == 1) {
$text .= ", one Nalimov hit";
$text .= sprintf ", %u Nalimov hits", $info->{'tbhits'};
}
}
- if (exists($info->{'seldepth'})) {
- $text .= sprintf " (%u selective)", $info->{'seldepth'};
- }
$text .= "\n\n";
}
sub score_sort_key {
my ($info, $pos, $mpv, $invert) = @_;
- $invert //= 0;
- if ($pos->{'toplay'} eq 'B') {
- $invert = !$invert;
- }
-
if (defined($info->{'score_mate' . $mpv})) {
if ($invert) {
return -(99999 - $info->{'score_mate' . $mpv});
} else {
if (exists($info->{'score_cp' . $mpv})) {
my $score = $info->{'score_cp' . $mpv};
- if ($score == 0) {
- return " 0.00";
- }
if ($invert) {
$score = -$score;
}
my $this = $refutation_moves{$move};
if ($this->{'depth'} < $best->{'depth'} ||
- ($this->{'depth'} == $best->{'depth'} && $this->{'score_cp'} < $best->{'score_cp'})) {
+ ($this->{'depth'} == $best->{'depth'} && score_sort_key($this, $pos, '', 1) > score_sort_key($best, $pos, '', 1))) {
$best_move = $move;
next;
}