rooklift / ogatak

KataGo analysis GUI and SGF editor
GNU Affero General Public License v3.0
83 stars 14 forks source link

Ideas / todo / etc #15

Open rooklift opened 3 years ago

rooklift commented 3 years ago

Stuff might be edited in and out of this comment as we go... note that these are ideas and suggestions, not necessarily things I actually want or will implement...

rooklift commented 2 years ago

Basic swing (delta) code:

    __draw_swings: function(node, vals, linewidth, colour) {

        let graph_length = node.graph_length_knower.val;

        let deltas = [];

        for (let n = 0; n < vals.length; n++) {
            if (typeof vals[n - 1] === "number" && typeof vals[n] === "number") {
                let d = vals[n] - vals[n - 1];
                deltas.push(d);
            } else {
                deltas.push(0);
            }
        }

        // Draw...

        let ctx = this.ctx;
        ctx.lineWidth = linewidth;
        ctx.strokeStyle = colour;

        for (let n = 0; n < deltas.length; n++) {

            if (!deltas[n]) continue;

            let gx = this.draw_x_offset + (this.drawable_width * 0.5);
            let gy = this.draw_y_offset + (this.drawable_height * n / graph_length);

            ctx.beginPath();
            ctx.moveTo(gx, gy);

            ctx.lineTo(gx + (deltas[n] * this.drawable_width), gy);
            ctx.stroke();
        }
    },
rooklift commented 2 years ago

Possibly prevent KataGo from illegally retaking a ko when we're not sending any history:

if (moves.length === 0) {

    // KataGo won't be able to infer the player to move without a history...

    o.initialPlayer = query_node.get_board().active.toUpperCase();

    // KataGo won't be able to infer any ko prohibition without a history...

    if (query_node.get_board().ko && query_node.get_board().ko_ban_player === query_node.get_board().active) {
        o.avoidMoves = [
            {
                player: query_node.get_board().active.toUpperCase(),
                moves: [query_node.get_board().gtp(query_node.get_board().ko)],
                untilDepth: 1,
            }
        ];
    }
}

But hmm, went with a different solution instead: e7d2263 - don't have such kos in the first place.

rooklift commented 2 years ago

For delayed mouseover PV...

"mouseover" events -->

"mouseleave" from the board (already present in __handlers.js) needs to now:

Problem: when new data comes in from the engine it will draw instantly (too soon).

rooklift commented 2 years ago

If the info panel will change for translation.

It's kind of baked-in at a fairly deep level. Well, not really, but I used monospace fonts as a lazy man's layout engine, and making things aesthetic with translations will be troublesome. I'm kind of happy to leave it for now...

Now for the change komi 7.5 to 6.5

I suppose it's not obvious but one can get from 7.5 to 6.5 by right clicking the number twice.

There are certainly too many options, it's true.

rooklift commented 2 years ago

KillerDucky's comments:

rooklift commented 2 years ago

Drawing score delta on the graph:

let s = node.depth.toString();

let parent_score = null;
let node_score = null;

if (node.parent) {
    if (node.parent.has_valid_analysis()) {
        parent_score = node.parent.analysis.rootInfo.scoreLead;
    } else {
        let ogsc = node.parent.get("OGSC");
        if (ogsc) {
            let score = parseFloat(ogsc);
            if (!Number.isNaN(score)) {
                parent_score = score;
            }
        }
    }
}

if (node.has_valid_analysis()) {
    node_score = node.analysis.rootInfo.scoreLead;
} else {
    let ogsc = node.get("OGSC");
    if (ogsc) {
        let score = parseFloat(ogsc);
        if (!Number.isNaN(score)) {
            node_score = score;
        }
    }
}

if (typeof parent_score === "number" && typeof node_score === "number") {
    s = `Δ ${Math.abs(node_score - parent_score).toFixed(1)}`;
}

Edit: this can be much more concise now that node.stored_score() and node.stored_winrate() exist.

rooklift commented 2 years ago
ctx.textAlign = "left";

if (!hub.__autoanalysis && !hub.__backanalysis && !hub.__autoplay && !hub.__play_colour) {
    if (node.parent) {
        if (config.graph_type === 1) {
            let parent_winrate = node.parent.stored_winrate();
            let node_winrate = node.stored_winrate();
            if (typeof parent_winrate === "number" && typeof node_winrate === "number") {
                let delta = (node_winrate - parent_winrate) * 100;
                ctx.fillText(
                    "Δ " + Math.abs(delta).toFixed(1),
                    this.draw_x_offset,
                    this.draw_y_offset + (this.drawable_height * node.depth / graph_depth) + 4
                );
            }
        } else if (config.graph_type === 2) {
            let parent_score = node.parent.stored_score();
            let node_score = node.stored_score();
            if (typeof parent_score === "number" && typeof node_score === "number") {
                let delta = node.stored_score() - node.parent.stored_score();
                ctx.fillText(
                    "Δ " + Math.abs(delta).toFixed(1),
                    this.draw_x_offset,
                    this.draw_y_offset + (this.drawable_height * node.depth / graph_depth) + 4
                );
            }
        }
    }
}
ParmuzinAlexander commented 1 year ago

How to translate something in " " ? s2 += ${override_moveinfo ? "${translate("INFO_PANEL_THIS")}" : "${translate("INFO_PANEL_BEST")}"}: <span class="white">${pad(move, 6)}</span>; Not work.

rooklift commented 1 year ago

To do that sort of templating stuff the string needs to be formatted with the ` character, also you don't need some of the " characters, I think in this exact case it should be...

s2 += `${override_moveinfo ? translate("INFO_PANEL_THIS") : translate("INFO_PANEL_BEST")}: <span class="white">${pad(move, 6)}</span>`;

Uh I have to warn you I can't guarantee I'll ever translate the infobox - it uses whitespace as a sort of lazy man's formatting tool and it won't work with different lengths of text, maybe...