let pv_score = undefined;
for (let move in data['refutation_lines']) {
let line = data['refutation_lines'][move];
- let score = compute_score_sort_key(line['score'], line['depth'], invert, false);
+ let score = compute_score_sort_key(line['score'], line['depth'], invert);
if (move == data['pv'][0]) {
pv_score = score;
}
* @param {string} fen
*/
let update_imbalance = function(fen) {
- let hiddenboard = new Chess(fen);
let imbalance = {'k': 0, 'q': 0, 'r': 0, 'b': 0, 'n': 0, 'p': 0};
- for (let row = 0; row < 8; ++row) {
- for (let col = 0; col < 8; ++col) {
- let col_text = String.fromCharCode('a1'.charCodeAt(0) + col);
- let row_text = String.fromCharCode('a1'.charCodeAt(1) + row);
- let square = col_text + row_text;
- let contents = hiddenboard.get(square);
- if (contents !== null) {
- if (contents.color === 'w') {
- ++imbalance[contents.type];
- } else {
- --imbalance[contents.type];
- }
- }
+ for (const c of fen) {
+ if (c === ' ') {
+ // End of board
+ break;
+ }
+ if (c != c.toUpperCase()) {
+ --imbalance[c];
+ } else if (c != c.toLowerCase()) {
+ ++imbalance[c.toLowerCase()];
}
}
+
let white_imbalance = document.getElementById('whiteimbalance');
let black_imbalance = document.getElementById('blackimbalance');
white_imbalance.textContent = '';
* @param score The score digest tuple.
* @param {?number} depth Depth the move has been computed to, or null.
* @param {boolean} invert Whether black is to play.
- * @param {boolean=} depth_secondary_key
* @return {number}
*/
-let compute_score_sort_key = function(score, depth, invert, depth_secondary_key) {
+let compute_score_sort_key = function(score, depth, invert) {
let s;
if (!score) {
return -10000000;
}
if (s) {
if (invert) s = -s;
- if (depth_secondary_key) {
- return s * 200 + (depth || 0);
- } else {
- return s;
- }
+ return s;
} else {
return null;
}