Skip to content

Commit

Permalink
Score estimator should use the original estimation values not autosco…
Browse files Browse the repository at this point in the history
…red values
  • Loading branch information
anoek committed Jun 3, 2024
1 parent b6ca994 commit 7e776c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/GobanCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3175,7 +3175,8 @@ export abstract class GobanCore extends EventEmitter<Events> {
this.engine,
AUTOSCORE_TRIALS,
AUTOSCORE_TOLERANCE,
true,
true /* prefer remote */,
true /* autoscore */,
);

se.when_ready
Expand Down Expand Up @@ -3914,10 +3915,12 @@ export abstract class GobanCore extends EventEmitter<Events> {
this.showMessage("processing", undefined, -1);
this.setMode("score estimation", true);
this.clearMessage();
const autoscore = false;
this.score_estimate = this.engine.estimateScore(
SCORE_ESTIMATION_TRIALS,
SCORE_ESTIMATION_TOLERANCE,
prefer_remote,
autoscore,
);
this.enableStonePlacement();
this.redraw(true);
Expand Down
15 changes: 9 additions & 6 deletions src/ScoreEstimator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@ export class ScoreEstimator {
prefer_remote: boolean;
autoscored_state?: JGOFNumericPlayerColor[][];
autoscored_removed?: string;
autoscore: boolean = false;

constructor(
goban_callback: GobanCore | undefined,
engine: GoEngine,
trials: number,
tolerance: number,
prefer_remote: boolean = false,
autoscore: boolean = false,
) {
this.goban_callback = goban_callback;

Expand All @@ -157,26 +159,27 @@ export class ScoreEstimator {
this.trials = trials;
this.tolerance = tolerance;
this.prefer_remote = prefer_remote;
this.autoscore = autoscore;

this.territory = GoMath.makeMatrix(this.width, this.height, 0);
this.groups = new GoStoneGroups(this);

this.when_ready = this.estimateScore(this.trials, this.tolerance);
this.when_ready = this.estimateScore(this.trials, this.tolerance, autoscore);
}

public estimateScore(trials: number, tolerance: number): Promise<void> {
public estimateScore(trials: number, tolerance: number, autoscore: boolean): Promise<void> {
if (!this.prefer_remote || this.height > 19 || this.width > 19) {
return this.estimateScoreLocal(trials, tolerance);
}

if (remote_scorer) {
return this.estimateScoreRemote();
return this.estimateScoreRemote(autoscore);
} else {
return this.estimateScoreLocal(trials, tolerance);
}
}

private estimateScoreRemote(): Promise<void> {
private estimateScoreRemote(autoscore: boolean): Promise<void> {
const komi = this.engine.komi;
const captures_delta = this.engine.score_prisoners
? this.engine.getBlackPrisoners() - this.engine.getWhitePrisoners()
Expand All @@ -202,7 +205,7 @@ export class ScoreEstimator {
height: this.engine.height,
rules: this.engine.rules,
board_state: board_state,
autoscore: true,
autoscore,
jwt: "", // this gets set by the remote_scorer method
})
.then((res: ScoreEstimateResponse) => {
Expand Down Expand Up @@ -335,7 +338,7 @@ export class ScoreEstimator {
this.toggleMetaGroupRemoval(i, j);
}

this.estimateScore(this.trials, this.tolerance).catch(() => {
this.estimateScore(this.trials, this.tolerance, this.autoscore).catch(() => {
/* empty */
});
}
Expand Down

0 comments on commit 7e776c4

Please sign in to comment.