Skip to content

Commit

Permalink
Switch graph to sigmoid
Browse files Browse the repository at this point in the history
  • Loading branch information
rooklift committed Sep 24, 2023
1 parent d59ff98 commit 34dba0a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
21 changes: 3 additions & 18 deletions files/src/renderer/50_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions files/src/renderer/51_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ 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.

let ret = [];
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;
}

Expand Down
2 changes: 1 addition & 1 deletion files/src/renderer/55_winrate_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 34dba0a

Please sign in to comment.