Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose Your Scorer #136

Merged
merged 8 commits into from
Nov 9, 2023
Merged

Choose Your Scorer #136

merged 8 commits into from
Nov 9, 2023

Conversation

benjaminpjones
Copy link
Contributor

@benjaminpjones benjaminpjones commented Nov 7, 2023

This PR adds the ability to choose between the OGS WASM estimator and a "Voronoi" estimator... or even a user-defined function.

WASM is still the default, but one can change the estimator like so:

goban.set_local_scorer(goban.estimateScoreVoronoi);

This is very useful for testing, since it was difficult to load the OGSScoreEstimator module in the test environment or mock it. This PR raises line coverage in ScoreEstimator.ts from 20% to 89%.


Incidentally, I believe the local scorer interface is compatible with @sabaki/influence, though I haven't tested it:

const influence = require('@sabaki/influence');
goban.set_local_scorer(influence.areaMap);

Screenshots of Voronoi scorer:

Screenshot 2023-11-07 at 10 54 49 PM Screenshot 2023-11-07 at 10 55 22 PM Screenshot 2023-11-07 at 10 57 31 PM

@benjaminpjones benjaminpjones marked this pull request as draft November 7, 2023 06:00
@benjaminpjones
Copy link
Contributor Author

benjaminpjones commented Nov 7, 2023

Converting to draft because I am comparing the "Voronoi" screenshots to stone.defender's images, and I think these differ on the borders. My implementation has large rectangular regions, but a true Voronoi diagram would fill until neutral areas have a width of at most 1 stone.

Screenshot 2023-11-06 at 10 06 00 PM

EDIT: Fixed in 30572d2

Screenshot 2023-11-07 at 11 00 48 PM

@anoek
Copy link
Member

anoek commented Nov 7, 2023

Very cool :)

It turns out the voronoi pattern is not the same as just getting
the "closest" color. This re-implementation leaves much less empty
space on the board.
@benjaminpjones benjaminpjones marked this pull request as ready for review November 8, 2023 07:00
@anoek anoek merged commit c110ad0 into online-go:main Nov 9, 2023
1 check passed
@anoek
Copy link
Member

anoek commented Nov 9, 2023

Pretty slick, thanks for working on this!

@benjaminpjones benjaminpjones deleted the choose-scorer-4 branch November 9, 2023 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants