client eval cache WIP. Problem: sending multiPv with initial anaDests
parent
2b6999d989
commit
31601fb913
|
@ -243,7 +243,6 @@ ul.ui-autocomplete li a.ui-state-focus {
|
|||
z-index: 2;
|
||||
width: 1.2em;
|
||||
height: 1.2em;
|
||||
cursor: default;
|
||||
outline:0;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
|
|
@ -438,6 +438,10 @@ module.exports = function(opts) {
|
|||
this.chessground.setAutoShapes(computeAutoShapes(this));
|
||||
}.bind(this);
|
||||
|
||||
var isEvalBetter = function(a, b) {
|
||||
return a.depth > b.depth || (a.depth === b.depth && a.nodes > b.nodes);
|
||||
};
|
||||
|
||||
var instanciateCeval = function(failsafe) {
|
||||
if (this.ceval) this.ceval.destroy();
|
||||
this.ceval = cevalCtrl({
|
||||
|
@ -451,9 +455,9 @@ module.exports = function(opts) {
|
|||
return;
|
||||
}
|
||||
if (work.threatMode) {
|
||||
if (!node.threat || node.threat.depth <= eval.depth || node.threat.maxDepth < eval.maxDepth)
|
||||
if (!node.threat || isEvalBetter(eval, node.threat) || node.threat.maxDepth < eval.maxDepth)
|
||||
node.threat = eval;
|
||||
} else if (!node.ceval || node.ceval.depth <= eval.depth || node.ceval.maxDepth < eval.maxDepth) {
|
||||
} else if (!node.ceval || isEvalBetter(eval, node.ceval) || eval.maxDepth > node.ceval.maxDepth) {
|
||||
var prevCloudDepth = node.ceval && node.ceval.cloud;
|
||||
node.ceval = eval;
|
||||
if (prevCloudDepth >= eval.depth) node.ceval.cloud = prevCloudDepth;
|
||||
|
|
|
@ -6,6 +6,13 @@ var evalPutMinNodes = 3e6;
|
|||
// var evalPutMinNodes = 1e6;
|
||||
var evalPutMaxMoves = 8;
|
||||
|
||||
/**
|
||||
* remembers the cloud eval depths seen for each FEN
|
||||
* so that we don't try to put an eval with a depth
|
||||
* lower than what the cloud already sent us.
|
||||
*/
|
||||
var fenCloudDepths = {};
|
||||
|
||||
function makeEvalPutData(eval) {
|
||||
return {
|
||||
fen: eval.fen,
|
||||
|
@ -31,7 +38,14 @@ module.exports = function(opts) {
|
|||
}
|
||||
}),
|
||||
mutateAnaDestsReq: function(req) {
|
||||
console.log(req, opts.canGet(), opts.getCeval().enabled());
|
||||
if (opts.canGet() && opts.getCeval().enabled()) req.multiPv = parseInt(opts.getCeval().multiPv());
|
||||
},
|
||||
onDests: function(data) {
|
||||
if (data.eval) {
|
||||
data.eval.cloud = data.eval.depth;
|
||||
console.log(data.eval, 'from cloud');
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -33,10 +33,7 @@ module.exports = function(send, ctrl) {
|
|||
},
|
||||
dests: function(data) {
|
||||
anaDestsCache[data.path] = data;
|
||||
if (data.eval) {
|
||||
data.eval.cloud = data.eval.depth;
|
||||
console.log(data.eval, 'from cloud');
|
||||
}
|
||||
ctrl.evalCache.onDests(data);
|
||||
ctrl.addDests(data.dests, data.path, data.opening, data.eval);
|
||||
clearTimeout(anaDestsTimeout);
|
||||
},
|
||||
|
|
|
@ -191,6 +191,7 @@ module.exports = function(opts) {
|
|||
if (!opts.possible || !allowed()) return;
|
||||
stop();
|
||||
enabled(!enabled());
|
||||
console.log('toggle', enabled());
|
||||
enableStorage.set(enabled() ? '1' : '0');
|
||||
},
|
||||
curDepth: function() {
|
||||
|
|
Loading…
Reference in New Issue