From 5c290f669c96dd5a695b9030dcde8c15fd30d5b5 Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Tue, 12 Sep 2023 19:22:05 +0100 Subject: [PATCH 01/13] Centipawn based graph, clamped at 2.5 & 1.0 lines --- files/src/renderer/50_table.js | 27 ++++++++++++++++++++++++++ files/src/renderer/51_node.js | 2 +- files/src/renderer/55_winrate_graph.js | 25 ++++++++++++------------ 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/files/src/renderer/50_table.js b/files/src/renderer/50_table.js index f6661d0e..2381c0b9 100644 --- a/files/src/renderer/50_table.js +++ b/files/src/renderer/50_table.js @@ -24,6 +24,7 @@ const table_prototype = { this.already_autopopulated = false; }, +/* get_eval: function() { if (this.eval_version === this.version) { return this.eval; @@ -38,6 +39,32 @@ const table_prototype = { return this.eval; } }, +*/ + + get_eval_adjusted: function() { + + // Napthalin's scheme: based on centipawns, +250 considered 100% winning. + // This is used solely for graphing. FIXME: name... + + if (this.eval_version === this.version) { + return this.eval; + } else { + let info = SortedMoveInfoFromTable(this)[0]; + if (info && !info.__ghost && info.__touched && (this.nodes > 1 || this.limit === 1)) { + let cp = info.cp; + if (info.board.active === "b") { + cp *= -1; + } + this.eval = (cp + 250) / 500; + if (this.eval < 0) this.eval = 0; + if (this.eval > 1) this.eval = 1; + } else { + this.eval = null; + } + this.eval_version = this.version; + return this.eval; + } + }, set_terminal_info: function(reason, ev) { // ev is ignored if reason is "" (i.e. not a terminal position) if (reason) { diff --git a/files/src/renderer/51_node.js b/files/src/renderer/51_node.js index b6e4099c..c08f8d0b 100644 --- a/files/src/renderer/51_node.js +++ b/files/src/renderer/51_node.js @@ -131,7 +131,7 @@ const node_prototype = { let node = this; while (node) { - ret.push(node.table.get_eval()); + ret.push(node.table.get_eval_adjusted()); // NOTE: this is the adjusted version based on -250 to 250 centipawn scale. node = node.parent; } diff --git a/files/src/renderer/55_winrate_graph.js b/files/src/renderer/55_winrate_graph.js index d174d222..d22c0b4b 100644 --- a/files/src/renderer/55_winrate_graph.js +++ b/files/src/renderer/55_winrate_graph.js @@ -3,7 +3,7 @@ function NewGrapher() { let grapher = Object.create(null); - + grapher.dragging = false; // Used by the event handlers in start.js grapher.clear_graph = function() { @@ -33,7 +33,7 @@ function NewGrapher() { let eval_list = node.future_eval_history(); - this.draw_50_percent_line(width, height); + this.draw_minus_one_plus_one_lines(width, height); this.draw_position_line(eval_list.length, node); // We make lists of contiguous edges that can be drawn at once... @@ -138,7 +138,7 @@ function NewGrapher() { return {normal_runs, dashed_runs}; }; - grapher.draw_50_percent_line = function(width, height) { + grapher.draw_minus_one_plus_one_lines = function(width, height) { // Avoid anti-aliasing... (FIXME: we assumed graph size was even) let pixel_y_adjustment = config.graph_line_width % 2 === 0 ? 0 : -0.5; @@ -147,8 +147,12 @@ function NewGrapher() { graphctx.lineWidth = config.graph_line_width; graphctx.setLineDash([config.graph_line_width, config.graph_line_width]); graphctx.beginPath(); - graphctx.moveTo(0, height / 2 + pixel_y_adjustment); - graphctx.lineTo(width, height / 2 + pixel_y_adjustment); + graphctx.moveTo(0, height * 0.3 + pixel_y_adjustment); + graphctx.lineTo(width, height * 0.3 + pixel_y_adjustment); + graphctx.stroke(); + graphctx.beginPath(); + graphctx.moveTo(0, height * 0.7 + pixel_y_adjustment); + graphctx.lineTo(width, height * 0.7 + pixel_y_adjustment); graphctx.stroke(); }; @@ -161,9 +165,8 @@ function NewGrapher() { let width = graph.width; let height = graph.height; - // Avoid anti-aliasing with x value, line up with 50 percent line (above) with y value... + // Avoid anti-aliasing... let pixel_x_adjustment = config.graph_line_width % 2 === 0 ? 0 : 0.5; - let pixel_y_adjustment = config.graph_line_width % 2 === 0 ? 0 : -0.5; let x = Math.floor(width * node.depth / node.graph_length_knower.val) + pixel_x_adjustment; @@ -172,14 +175,10 @@ function NewGrapher() { graphctx.setLineDash([config.graph_line_width, config.graph_line_width]); graphctx.beginPath(); - graphctx.moveTo(x, height / 2 + pixel_y_adjustment - config.graph_line_width - 1); - graphctx.lineTo(x, 0); - graphctx.stroke(); - - graphctx.beginPath(); - graphctx.moveTo(x, height / 2 + pixel_y_adjustment + config.graph_line_width + 1); + graphctx.moveTo(x, 0); graphctx.lineTo(x, height); graphctx.stroke(); + }; grapher.node_from_click = function(node, event) { From c7217b0c525e429919f5e24f4246c25d50e46f56 Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Tue, 12 Sep 2023 19:25:24 +0100 Subject: [PATCH 02/13] Comment --- files/src/renderer/55_winrate_graph.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/src/renderer/55_winrate_graph.js b/files/src/renderer/55_winrate_graph.js index d22c0b4b..10736fae 100644 --- a/files/src/renderer/55_winrate_graph.js +++ b/files/src/renderer/55_winrate_graph.js @@ -140,6 +140,9 @@ function NewGrapher() { grapher.draw_minus_one_plus_one_lines = function(width, height) { + // Note: this draws lines at 30% and 70%, which lines up with -1.0 and +1.0 centipawn + // scores when we use Naphthalin's centipawn graph which is clamped at -2.5 and +2.5. + // Avoid anti-aliasing... (FIXME: we assumed graph size was even) let pixel_y_adjustment = config.graph_line_width % 2 === 0 ? 0 : -0.5; From dbc870151b45deff37b20594afc16574b4e710af Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Tue, 12 Sep 2023 19:33:36 +0100 Subject: [PATCH 03/13] naming things --- files/src/renderer/51_node.js | 10 ++++------ files/src/renderer/55_winrate_graph.js | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/files/src/renderer/51_node.js b/files/src/renderer/51_node.js index c08f8d0b..30c55864 100644 --- a/files/src/renderer/51_node.js +++ b/files/src/renderer/51_node.js @@ -125,10 +125,12 @@ const node_prototype = { return ret; }, - eval_history: function() { + all_evals_for_graph: function() { + + // Call this on any node in the line will give the same result. let ret = []; - let node = this; + let node = this.get_end(); while (node) { ret.push(node.table.get_eval_adjusted()); // NOTE: this is the adjusted version based on -250 to 250 centipawn scale. @@ -147,10 +149,6 @@ const node_prototype = { return this.get_end().node_history(); }, - future_eval_history: function() { - return this.get_end().eval_history(); - }, - get_root: function() { let node = this; diff --git a/files/src/renderer/55_winrate_graph.js b/files/src/renderer/55_winrate_graph.js index 10736fae..bf11a315 100644 --- a/files/src/renderer/55_winrate_graph.js +++ b/files/src/renderer/55_winrate_graph.js @@ -31,7 +31,7 @@ function NewGrapher() { let width = graph.width; // After the above. let height = graph.height; - let eval_list = node.future_eval_history(); + let eval_list = node.all_evals_for_graph(); this.draw_minus_one_plus_one_lines(width, height); this.draw_position_line(eval_list.length, node); From 7d1405b18b372443b11a47be5c473c6c3dc7bea6 Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Tue, 12 Sep 2023 19:36:32 +0100 Subject: [PATCH 04/13] Naming things --- files/src/renderer/55_winrate_graph.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/src/renderer/55_winrate_graph.js b/files/src/renderer/55_winrate_graph.js index bf11a315..8b50b56e 100644 --- a/files/src/renderer/55_winrate_graph.js +++ b/files/src/renderer/55_winrate_graph.js @@ -33,7 +33,7 @@ function NewGrapher() { let eval_list = node.all_evals_for_graph(); - this.draw_minus_one_plus_one_lines(width, height); + this.draw_30_70_lines(width, height); this.draw_position_line(eval_list.length, node); // We make lists of contiguous edges that can be drawn at once... @@ -138,7 +138,7 @@ function NewGrapher() { return {normal_runs, dashed_runs}; }; - grapher.draw_minus_one_plus_one_lines = function(width, height) { + grapher.draw_30_70_lines = function(width, height) { // Note: this draws lines at 30% and 70%, which lines up with -1.0 and +1.0 centipawn // scores when we use Naphthalin's centipawn graph which is clamped at -2.5 and +2.5. From 8d82fa4c2e7f1f3219ae127587347e1f68662ae5 Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Tue, 12 Sep 2023 19:50:06 +0100 Subject: [PATCH 05/13] Naming things; rm old get_eval() --- files/src/renderer/50_table.js | 43 ++++++++------------------ files/src/renderer/51_node.js | 6 ++-- files/src/renderer/55_winrate_graph.js | 2 +- 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/files/src/renderer/50_table.js b/files/src/renderer/50_table.js index 2381c0b9..49b005cb 100644 --- a/files/src/renderer/50_table.js +++ b/files/src/renderer/50_table.js @@ -19,35 +19,18 @@ const table_prototype = { this.time = 0; // Stat sent by engine this.limit = null; // The limit of the last search that updated this. this.terminal = null; // null = unknown, "" = not terminal, "Non-empty string" = terminal reason - this.eval = null; // Used by grapher only, value from White's POV - this.eval_version = 0; // Which version (above) was used to generate the eval + this.graph_y = null; // Used by grapher only, value from White's POV between 0 and 1 + this.graph_y_version = 0; // Which version (above) was used to generate the graph_y value this.already_autopopulated = false; }, -/* - get_eval: function() { - if (this.eval_version === this.version) { - return this.eval; - } else { - let info = SortedMoveInfoFromTable(this)[0]; - if (info && !info.__ghost && info.__touched && (this.nodes > 1 || this.limit === 1)) { - this.eval = info.board.active === "w" ? info.value() : 1 - info.value(); - } else { - this.eval = null; - } - this.eval_version = this.version; - return this.eval; - } - }, -*/ - - get_eval_adjusted: function() { + get_graph_y: function() { // Napthalin's scheme: based on centipawns, +250 considered 100% winning. // This is used solely for graphing. FIXME: name... - if (this.eval_version === this.version) { - return this.eval; + if (this.graph_y_version === this.version) { + return this.graph_y; } else { let info = SortedMoveInfoFromTable(this)[0]; if (info && !info.__ghost && info.__touched && (this.nodes > 1 || this.limit === 1)) { @@ -55,22 +38,22 @@ const table_prototype = { if (info.board.active === "b") { cp *= -1; } - this.eval = (cp + 250) / 500; - if (this.eval < 0) this.eval = 0; - if (this.eval > 1) this.eval = 1; + this.graph_y = (cp + 250) / 500; + if (this.graph_y < 0) this.graph_y = 0; + if (this.graph_y > 1) this.graph_y = 1; } else { - this.eval = null; + this.graph_y = null; } - this.eval_version = this.version; - return this.eval; + this.graph_y_version = this.version; + return this.graph_y; } }, set_terminal_info: function(reason, ev) { // ev is ignored if reason is "" (i.e. not a terminal position) if (reason) { this.terminal = reason; - this.eval = ev; - this.eval_version = this.version; + this.graph_y = ev; + this.graph_y_version = this.version; } else { this.terminal = ""; } diff --git a/files/src/renderer/51_node.js b/files/src/renderer/51_node.js index 30c55864..4f2282ff 100644 --- a/files/src/renderer/51_node.js +++ b/files/src/renderer/51_node.js @@ -125,7 +125,7 @@ const node_prototype = { return ret; }, - all_evals_for_graph: function() { + all_graph_values: function() { // Call this on any node in the line will give the same result. @@ -133,7 +133,7 @@ const node_prototype = { let node = this.get_end(); while (node) { - ret.push(node.table.get_eval_adjusted()); // NOTE: this is the adjusted version based on -250 to 250 centipawn scale. + ret.push(node.table.get_graph_y()); node = node.parent; } @@ -348,7 +348,7 @@ const node_prototype = { terminal_reason: function() { // Returns "" if not a terminal position, otherwise returns the reason. - // Also updates table.eval (for the graph) if needed. + // Also updates table.graph_y if needed. if (typeof this.table.terminal === "string") { return this.table.terminal; diff --git a/files/src/renderer/55_winrate_graph.js b/files/src/renderer/55_winrate_graph.js index 8b50b56e..141b3a71 100644 --- a/files/src/renderer/55_winrate_graph.js +++ b/files/src/renderer/55_winrate_graph.js @@ -31,7 +31,7 @@ function NewGrapher() { let width = graph.width; // After the above. let height = graph.height; - let eval_list = node.all_evals_for_graph(); + let eval_list = node.all_graph_values(); this.draw_30_70_lines(width, height); this.draw_position_line(eval_list.length, node); From b3c01b76a42cc3b4b09dd07039f666cb177e0a90 Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Tue, 12 Sep 2023 19:52:17 +0100 Subject: [PATCH 06/13] Update 50_table.js --- files/src/renderer/50_table.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/src/renderer/50_table.js b/files/src/renderer/50_table.js index 49b005cb..18b4a837 100644 --- a/files/src/renderer/50_table.js +++ b/files/src/renderer/50_table.js @@ -27,7 +27,7 @@ const table_prototype = { get_graph_y: function() { // Napthalin's scheme: based on centipawns, +250 considered 100% winning. - // This is used solely for graphing. FIXME: name... + // This is used solely for graphing. if (this.graph_y_version === this.version) { return this.graph_y; From dcbe0ed9689cb7d2da90518ec3e56c51c8606de9 Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Tue, 12 Sep 2023 19:53:53 +0100 Subject: [PATCH 07/13] Update 50_table.js --- files/src/renderer/50_table.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/src/renderer/50_table.js b/files/src/renderer/50_table.js index 18b4a837..ab81bd71 100644 --- a/files/src/renderer/50_table.js +++ b/files/src/renderer/50_table.js @@ -26,7 +26,7 @@ const table_prototype = { get_graph_y: function() { - // Napthalin's scheme: based on centipawns, +250 considered 100% winning. + // Naphthalin's scheme: based on centipawns, +250 considered 100% winning. // This is used solely for graphing. if (this.graph_y_version === this.version) { From 4bdb87ca8e71876da0ea7c9a48ba0d130c27be7f Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Tue, 12 Sep 2023 20:37:41 +0100 Subject: [PATCH 08/13] less hardcoded --- files/src/renderer/50_table.js | 7 +++---- files/src/renderer/51_node.js | 4 ++-- files/src/renderer/55_winrate_graph.js | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/files/src/renderer/50_table.js b/files/src/renderer/50_table.js index ab81bd71..394bf82d 100644 --- a/files/src/renderer/50_table.js +++ b/files/src/renderer/50_table.js @@ -24,10 +24,9 @@ const table_prototype = { this.already_autopopulated = false; }, - get_graph_y: function() { + get_graph_y: function(cp_clamp) { // e.g. a value of 250 will mean +250 is drawn as if it's 100% winning. - // Naphthalin's scheme: based on centipawns, +250 considered 100% winning. - // This is used solely for graphing. + // Naphthalin's scheme: based on centipawns. if (this.graph_y_version === this.version) { return this.graph_y; @@ -38,7 +37,7 @@ const table_prototype = { if (info.board.active === "b") { cp *= -1; } - this.graph_y = (cp + 250) / 500; + this.graph_y = (cp + cp_clamp) / (cp_clamp * 2); if (this.graph_y < 0) this.graph_y = 0; if (this.graph_y > 1) this.graph_y = 1; } else { diff --git a/files/src/renderer/51_node.js b/files/src/renderer/51_node.js index 4f2282ff..a995de32 100644 --- a/files/src/renderer/51_node.js +++ b/files/src/renderer/51_node.js @@ -125,7 +125,7 @@ const node_prototype = { return ret; }, - all_graph_values: function() { + all_graph_values: function(cp_clamp) { // cp_clamp: how many centipawns (e.g. 250) to consider absolutely winning... // Call this on any node in the line will give the same result. @@ -133,7 +133,7 @@ const node_prototype = { let node = this.get_end(); while (node) { - ret.push(node.table.get_graph_y()); + ret.push(node.table.get_graph_y(cp_clamp)); node = node.parent; } diff --git a/files/src/renderer/55_winrate_graph.js b/files/src/renderer/55_winrate_graph.js index 141b3a71..7b4e20ca 100644 --- a/files/src/renderer/55_winrate_graph.js +++ b/files/src/renderer/55_winrate_graph.js @@ -31,7 +31,7 @@ function NewGrapher() { let width = graph.width; // After the above. let height = graph.height; - let eval_list = node.all_graph_values(); + let eval_list = node.all_graph_values(250); this.draw_30_70_lines(width, height); this.draw_position_line(eval_list.length, node); From 259b872cad36f154b4106e1644d14962d3bb3aa2 Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Tue, 12 Sep 2023 20:41:55 +0100 Subject: [PATCH 09/13] less hardcoded --- files/src/renderer/55_winrate_graph.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/files/src/renderer/55_winrate_graph.js b/files/src/renderer/55_winrate_graph.js index 7b4e20ca..5ca18159 100644 --- a/files/src/renderer/55_winrate_graph.js +++ b/files/src/renderer/55_winrate_graph.js @@ -31,9 +31,8 @@ function NewGrapher() { let width = graph.width; // After the above. let height = graph.height; - let eval_list = node.all_graph_values(250); - - this.draw_30_70_lines(width, height); + let eval_list = node.all_graph_values(250); // Centipawn value to clamp the graph at. + this.draw_horizontal_lines(width, height, [0.3, 0.7]); // 0.3 and 0.7 goes well with 250 (draws lines at +/- 100 cp). this.draw_position_line(eval_list.length, node); // We make lists of contiguous edges that can be drawn at once... @@ -138,7 +137,7 @@ function NewGrapher() { return {normal_runs, dashed_runs}; }; - grapher.draw_30_70_lines = function(width, height) { + grapher.draw_horizontal_lines = function(width, height, y_fractions = [0.5]) { // Note: this draws lines at 30% and 70%, which lines up with -1.0 and +1.0 centipawn // scores when we use Naphthalin's centipawn graph which is clamped at -2.5 and +2.5. @@ -149,14 +148,13 @@ function NewGrapher() { graphctx.strokeStyle = "#666666"; graphctx.lineWidth = config.graph_line_width; graphctx.setLineDash([config.graph_line_width, config.graph_line_width]); - graphctx.beginPath(); - graphctx.moveTo(0, height * 0.3 + pixel_y_adjustment); - graphctx.lineTo(width, height * 0.3 + pixel_y_adjustment); - graphctx.stroke(); - graphctx.beginPath(); - graphctx.moveTo(0, height * 0.7 + pixel_y_adjustment); - graphctx.lineTo(width, height * 0.7 + pixel_y_adjustment); - graphctx.stroke(); + + for (let y_fraction of y_fractions) { + graphctx.beginPath(); + graphctx.moveTo(0, height * y_fraction + pixel_y_adjustment); + graphctx.lineTo(width, height * y_fraction + pixel_y_adjustment); + graphctx.stroke(); + } }; grapher.draw_position_line = function(eval_list_length, node) { From 901e7bf8073ecf5c89ce5d8280d56681b96f4381 Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Tue, 12 Sep 2023 20:53:10 +0100 Subject: [PATCH 10/13] rm old comment --- files/src/renderer/55_winrate_graph.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/files/src/renderer/55_winrate_graph.js b/files/src/renderer/55_winrate_graph.js index 5ca18159..2a92d815 100644 --- a/files/src/renderer/55_winrate_graph.js +++ b/files/src/renderer/55_winrate_graph.js @@ -139,9 +139,6 @@ function NewGrapher() { grapher.draw_horizontal_lines = function(width, height, y_fractions = [0.5]) { - // Note: this draws lines at 30% and 70%, which lines up with -1.0 and +1.0 centipawn - // scores when we use Naphthalin's centipawn graph which is clamped at -2.5 and +2.5. - // Avoid anti-aliasing... (FIXME: we assumed graph size was even) let pixel_y_adjustment = config.graph_line_width % 2 === 0 ? 0 : -0.5; From 58e52bde197a05e2b656fd6e06ba1949b5776c5a Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Sun, 24 Sep 2023 14:39:22 +0100 Subject: [PATCH 11/13] Incorporate Naphthalin's stuff --- files/src/renderer/50_table.js | 23 ++++++++++++++++++----- files/src/renderer/55_winrate_graph.js | 4 ++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/files/src/renderer/50_table.js b/files/src/renderer/50_table.js index 394bf82d..78c4dbd2 100644 --- a/files/src/renderer/50_table.js +++ b/files/src/renderer/50_table.js @@ -24,9 +24,13 @@ const table_prototype = { this.already_autopopulated = false; }, - get_graph_y: function(cp_clamp) { // e.g. a value of 250 will mean +250 is drawn as if it's 100% winning. + get_graph_y: function(cp_clamp) { - // Naphthalin's scheme: based on centipawns. + // Naphthalin's scheme: based on centipawns. The clamping is now "soft". + // A cp_clamp value of 250 will make the graph linear between -250 and 250 centipawns, and squash beyond that + // until -500 or 500, at which point it is fully clamped (i.e. treated as 100% losing / winning). + // + // Note that this is independent of where the horizontal lines are drawn on the graph. if (this.graph_y_version === this.version) { return this.graph_y; @@ -37,9 +41,18 @@ const table_prototype = { if (info.board.active === "b") { cp *= -1; } - this.graph_y = (cp + cp_clamp) / (cp_clamp * 2); - if (this.graph_y < 0) this.graph_y = 0; - if (this.graph_y > 1) this.graph_y = 1; + let raw = cp / cp_clamp; + if (raw < -2) { + this.graph_y = 0; // score was very low: below double the negative clamp + } else if (raw < -1) { + this.graph_y = (raw + 2) / 12; // score was low: below the negative clamp + } else if (raw < 1) { + this.graph_y = 0.5 + (raw / 2.4); // score was in the critical strip between clamps + } else if (raw < 2) { + this.graph_y = 1.0 + (raw - 2) / 12; // score was high: above the positive clamp + } else { + this.graph_y = 1; // score was very high: above double the positive clamp + } } else { this.graph_y = null; } diff --git a/files/src/renderer/55_winrate_graph.js b/files/src/renderer/55_winrate_graph.js index 2a92d815..3117f6b6 100644 --- a/files/src/renderer/55_winrate_graph.js +++ b/files/src/renderer/55_winrate_graph.js @@ -31,8 +31,8 @@ function NewGrapher() { let width = graph.width; // After the above. let height = graph.height; - let eval_list = node.all_graph_values(250); // Centipawn value to clamp the graph at. - this.draw_horizontal_lines(width, height, [0.3, 0.7]); // 0.3 and 0.7 goes well with 250 (draws lines at +/- 100 cp). + let eval_list = node.all_graph_values(250); // Centipawn value to "soft clamp" the graph at. + this.draw_horizontal_lines(width, height, [1/3, 2/3]); this.draw_position_line(eval_list.length, node); // We make lists of contiguous edges that can be drawn at once... From d59ff981373a264f3c32662d3c98d70f354e5d1e Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Sun, 24 Sep 2023 14:44:52 +0100 Subject: [PATCH 12/13] Update 50_table.js --- files/src/renderer/50_table.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/src/renderer/50_table.js b/files/src/renderer/50_table.js index 78c4dbd2..bc302dd5 100644 --- a/files/src/renderer/50_table.js +++ b/files/src/renderer/50_table.js @@ -47,7 +47,7 @@ const table_prototype = { } else if (raw < -1) { this.graph_y = (raw + 2) / 12; // score was low: below the negative clamp } else if (raw < 1) { - this.graph_y = 0.5 + (raw / 2.4); // score was in the critical strip between clamps + this.graph_y = 0.5 + (raw / 2.4); // score was between clamps - note this is NOT necessarily the graph's critical strip } else if (raw < 2) { this.graph_y = 1.0 + (raw - 2) / 12; // score was high: above the positive clamp } else { From 34dba0a36faeb100126f9d7295d373f2f61b1fc2 Mon Sep 17 00:00:00 2001 From: rooklift <16438795+rooklift@users.noreply.github.com> Date: Sun, 24 Sep 2023 16:20:27 +0100 Subject: [PATCH 13/13] Switch graph to sigmoid --- files/src/renderer/50_table.js | 21 +++------------------ files/src/renderer/51_node.js | 4 ++-- files/src/renderer/55_winrate_graph.js | 2 +- 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/files/src/renderer/50_table.js b/files/src/renderer/50_table.js index bc302dd5..9e081891 100644 --- a/files/src/renderer/50_table.js +++ b/files/src/renderer/50_table.js @@ -24,13 +24,9 @@ const table_prototype = { this.already_autopopulated = false; }, - get_graph_y: function(cp_clamp) { + get_graph_y: function() { - // Naphthalin's scheme: based on centipawns. The clamping is now "soft". - // A cp_clamp value of 250 will make the graph linear between -250 and 250 centipawns, and squash beyond that - // until -500 or 500, at which point it is fully clamped (i.e. treated as 100% losing / winning). - // - // Note that this is independent of where the horizontal lines are drawn on the graph. + // Naphthalin's scheme: based on centipawns. if (this.graph_y_version === this.version) { return this.graph_y; @@ -41,18 +37,7 @@ const table_prototype = { if (info.board.active === "b") { cp *= -1; } - let raw = cp / cp_clamp; - if (raw < -2) { - this.graph_y = 0; // score was very low: below double the negative clamp - } else if (raw < -1) { - this.graph_y = (raw + 2) / 12; // score was low: below the negative clamp - } else if (raw < 1) { - this.graph_y = 0.5 + (raw / 2.4); // score was between clamps - note this is NOT necessarily the graph's critical strip - } else if (raw < 2) { - this.graph_y = 1.0 + (raw - 2) / 12; // score was high: above the positive clamp - } else { - this.graph_y = 1; // score was very high: above double the positive clamp - } + this.graph_y = 1 / (1 + Math.pow(0.5, cp / 100)); } else { this.graph_y = null; } diff --git a/files/src/renderer/51_node.js b/files/src/renderer/51_node.js index a995de32..4f2282ff 100644 --- a/files/src/renderer/51_node.js +++ b/files/src/renderer/51_node.js @@ -125,7 +125,7 @@ const node_prototype = { return ret; }, - all_graph_values: function(cp_clamp) { // cp_clamp: how many centipawns (e.g. 250) to consider absolutely winning... + all_graph_values: function() { // Call this on any node in the line will give the same result. @@ -133,7 +133,7 @@ const node_prototype = { let node = this.get_end(); while (node) { - ret.push(node.table.get_graph_y(cp_clamp)); + ret.push(node.table.get_graph_y()); node = node.parent; } diff --git a/files/src/renderer/55_winrate_graph.js b/files/src/renderer/55_winrate_graph.js index 3117f6b6..2e291d44 100644 --- a/files/src/renderer/55_winrate_graph.js +++ b/files/src/renderer/55_winrate_graph.js @@ -31,7 +31,7 @@ function NewGrapher() { let width = graph.width; // After the above. let height = graph.height; - let eval_list = node.all_graph_values(250); // Centipawn value to "soft clamp" the graph at. + let eval_list = node.all_graph_values(); this.draw_horizontal_lines(width, height, [1/3, 2/3]); this.draw_position_line(eval_list.length, node);