sort pvs in local eval: stockfish does not always do it

pull/2816/head
Thibault Duplessis 2017-03-19 16:53:45 +01:00
parent 8df755b925
commit 493363c4e3
1 changed files with 8 additions and 0 deletions

View File

@ -4,6 +4,7 @@ var median = require('./math').median;
var storedProp = require('common').storedProp;
var throttle = require('common').throttle;
var stockfishProtocol = require('./stockfishProtocol');
var povChances = require('./winningChances').povChances;
module.exports = function(opts) {
@ -76,6 +77,7 @@ module.exports = function(opts) {
if (pv.cp) pv.cp = -pv.cp;
if (pv.mate) pv.mate = -pv.mate;
});
sortPvsInPlace(eval.pvs, work.ply % 2 === (work.threatMode ? 1 : 0) ? 'white' : 'black');
npsRecorder(eval);
curEval = eval;
throttledEmit(eval, work);
@ -90,6 +92,12 @@ module.exports = function(opts) {
return (isDeeper() || infinite()) ? 99 : parseInt(maxDepth());
};
var sortPvsInPlace = function(pvs, color) {
pvs.sort(function(a, b) {
return povChances(color, b) - povChances(color, a);
});
};
var start = function(path, steps, threatMode, deeper) {
if (!enabled() || !opts.possible) return;