Skip to content

Commit

Permalink
No functional change.
Browse files Browse the repository at this point in the history
Reduce potential merge conflicts w/ rooklift#248
  • Loading branch information
yuzisee committed Sep 29, 2023
1 parent 914bba0 commit 1b41cbf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
22 changes: 10 additions & 12 deletions files/src/renderer/50_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ const table_prototype = {
this.already_autopopulated = false;
},

get_cp: function() {
get_cp_details: function() {
let info = SortedMoveInfoFromTable(this)[0];
if (info && !info.__ghost && info.__touched && (this.nodes > 1 || this.limit === 1)) {
if (info.board.active === "b") {
return -info.cp;
} else {
return info.cp;
}
let return_cp = ((info.board.active === "b") ? (-info.cp) : (info.cp));
return {
'cp': return_cp
};
} else {
return null;
}
Expand All @@ -41,18 +40,17 @@ const table_prototype = {

// Naphthalin's scheme: based on centipawns.

if (this.graph_y_version === this.version) {
return this.graph_y;
} else {
let cp = this.get_cp();
if (cp !== null) {
if (this.graph_y_version !== this.version) {
let engine_info_graph_details = this.get_cp_details();
if (engine_info_graph_details !== null) {
let cp = engine_info_graph_details.cp;
this.graph_y = 1 / (1 + Math.pow(0.5, cp / 100));
} else {
this.graph_y = null;
}
this.graph_y_version = this.version;
return this.graph_y;
}
return this.graph_y;
},

set_terminal_info: function(reason, ev) { // ev is ignored if reason is "" (i.e. not a terminal position)
Expand Down
9 changes: 6 additions & 3 deletions files/src/renderer/72_tree_draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ let tree_draw_props = {
// Helpers...

underline_html_classlist: function (eval_node, dom_classlist) {
let eval_node_cp = eval_node.table.get_cp();
let eval_parentnode_cp = eval_node.parent.table.get_cp();
if ( ((typeof eval_node_cp) == 'number') && ((typeof eval_parentnode_cp) == 'number') ) {
let eval_node_details = eval_node.table.get_cp_details();
let eval_parentnode_details = eval_node.parent.table.get_cp_details();
if ( (eval_node_details !== null) && (eval_parentnode_details !== null) ) {
if ((dom_classlist.length > 0) && (dom_classlist instanceof DOMTokenList)) {
// NOTE: we don't need to `.remove` when `dom_classlist instanceof Array` because
// dom_from_scratch is recreating elements from the ground up (they won't have classes we need to remove)
Expand All @@ -176,6 +176,9 @@ let tree_draw_props = {
dom_classlist.remove('underline-blunder');
}

let eval_node_cp = eval_node_details.cp;
let eval_parentnode_cp = eval_parentnode_details.cp;

let clamped_eval_node_cp = Math.min(Math.max(eval_node_cp, -250), 250);
let clamped_eval_parentnode_cp = Math.min(Math.max(eval_parentnode_cp, -250), 250);
let clamped_delta_centipawns = Math.abs(clamped_eval_node_cp - clamped_eval_parentnode_cp);
Expand Down

0 comments on commit 1b41cbf

Please sign in to comment.