]> git.sesse.net Git - remoteglot/commitdiff
Use the prettyprinted files from the protobuf. Leave the old code in place in case...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 20 Nov 2016 21:34:35 +0000 (22:34 +0100)
committerMagne Mæhre <magne@pannekake.samfundet.no>
Sun, 20 Nov 2016 21:34:35 +0000 (22:34 +0100)
server/hash-lookup.js
server/hashprobe.proto

index dd0b0c3160633d643271606cd397916584a907b0..3ee6bd3ad1643a1ef4ea711e34ad80604c3587ad 100644 (file)
@@ -68,11 +68,11 @@ var handle_response = function(fen, response, probe_responses) {
        var probe_response = reconcile_responses(probe_responses);
        var lines = {};
 
        var probe_response = reconcile_responses(probe_responses);
        var lines = {};
 
-       var root = translate_line(board, fen, probe_response['root']);
+       var root = translate_line_use_pretty(board, fen, probe_response['root']);
        for (var i = 0; i < probe_response['line'].length; ++i) {
                var line = probe_response['line'][i];
                var uci_move = line['move']['from_sq'] + line['move']['to_sq'] + line['move']['promotion'];
        for (var i = 0; i < probe_response['line'].length; ++i) {
                var line = probe_response['line'][i];
                var uci_move = line['move']['from_sq'] + line['move']['to_sq'] + line['move']['promotion'];
-               lines[uci_move] = translate_line(board, fen, line);
+               lines[uci_move] = translate_line_use_pretty(board, fen, line);
        }
 
        var text = JSON.stringify({
        }
 
        var text = JSON.stringify({
@@ -197,3 +197,49 @@ var translate_line = function(board, fen, line) {
 
        return r;
 }
 
        return r;
 }
+
+var translate_line_use_pretty = function(board, fen, line) {
+       var r = {};
+
+       if (line['move'] && line['move']['pretty']) {
+               r['move'] = line['move']['pretty']
+       } else {
+               r['move'] = '';
+       }
+       if (!line['found']) {
+               r['pv'] = [];
+               return r;
+       }
+       r['depth'] = line['depth'];
+
+       // Convert the PV.
+       var pv = [];
+       if (r['move']) {
+               pv.push(r['move']);
+       }
+       for (var j = 0; j < line['pv'].length; ++j) {
+               var move = line['pv'][j];
+               pv.push(move['pretty']);
+       }
+       r['pv'] = pv;
+
+       // Convert the score. Use the static eval if no search.
+       var value = line['value'] || line['eval'];
+       var score = null;
+       if (value['score_type'] === 'SCORE_CP') {
+               score = ['cp', value['score_cp']];
+       } else if (value['score_type'] === 'SCORE_MATE') {
+               score = ['m', value['score_mate']];
+       }
+       if (score) {
+               if (line['bound'] === 'BOUND_UPPER') {
+                       score.push('≤');
+               } else if (line['bound'] === 'BOUND_LOWER') {
+                       score.push('≥');
+               }
+       }
+
+       r['score'] = score;
+
+       return r;
+}
index bb34806dfdc53a3a13fdbe5e679d34b987011231..175cd7731a32784054db230a74af697815e605e0 100644 (file)
@@ -30,6 +30,8 @@ message HashProbeMove {
        string from_sq = 1;  // a1, a2, etc.
        string to_sq = 2;
        string promotion = 3;  // Q, R, etc.
        string from_sq = 1;  // a1, a2, etc.
        string to_sq = 2;
        string promotion = 3;  // Q, R, etc.
+
+       string pretty = 4;  // e.g. Rxf6+
 }
 message HashProbeScore {
        enum ScoreType {
 }
 message HashProbeScore {
        enum ScoreType {