-
Notifications
You must be signed in to change notification settings - Fork 39
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
Clean up ScoreEstimator.ts #135
Clean up ScoreEstimator.ts #135
Conversation
Reasoning: the wait_for promise is not awaited, so the result of getProbablyDead is meaningless here.
This function is only ever called on a prefer_remote SE. Also, the ownership/tolerance calculation should still be valid with WASM if ever needs to be used like that.
This looks like a copy of ScoreEstimator.area and is never used.
This helps with testing, and also will allow us to do the same adjustments with other scoring algorithms.
These are both derived from ownership. area appears to be unused, and heat is used in GobanCanvas, but can just be replaced with ownership.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, this is some pretty dusty code, and you'll make a lot of people happy (myself included) if you can make it less dumb (but not too smart either!).
Regarding the not too smart part - when I introduced the KataGo backend the community basically said it was too smart, which is why we still have that WASM backend for live game estimates, so that's something to keep in mind when pondering your JS backend and for revising things to be less dumb.
Less dumb is good, too good at the game is bad, but if we can work towards some sweet spot in-between that's great :)
Anyways, I always love your refactors, thanks for taking this one on!
src/ScoreEstimator.ts
Outdated
export interface ScoreEstimateRequest { | ||
player_to_move: "black" | "white"; | ||
width: number; | ||
height: number; | ||
board_state: Array<Array<number>>; | ||
rules: GoEngineRules; | ||
black_prisoners?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are still used on the backend, ogs-node
repository
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point it might make more sense to have a separate type for the score estimate requests sent off to the server that include these, I'd be OK with that too depending on how much you want to change. It's convenient to have it somewhere in the goban repository that way both the UI and the server side can use it, although on the flip side maybe it still makes a bit of sense too to have a common ScoreEstimateRequest structure depending on which backend we're using, the WASM module, the server KataGo system, or the newfangled JS backend you have in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, and added back in! I don't really have a preference regarding separate types or a unified type, but I'll keep it as-is in this PR to minimize downstream churn.
These properties are still referenced on the backend.
Thanks for reviewing! Definitely makes sense to want a "dumb" in-game estimator. The algorithms I'd like to experiment with are geometric and have no knowledge of Go (variations on the Voronoi algorithm from this thread), so I don't think they should be perceived as too smart at all. |
I've wanted to play with ScoreEstimator for a while, but there is a lot going on in there, and it's not easy to test due to external dependencies on OGSScoreEstimator (c++ WASM lib) and the remote AI scorer. I figured the best way to approach this is to clean it up as much as I can in one pass and manually test all changes together. That said, let me know if there are commits that aren't desired, it shouldn't be too hard for me to remove them.
Motivations
Observations
Assumptions
Please let me know if these are invalid. If you have code snippets on external usages, I can create additional unit tests to help capture the behavior (similar to the "amount and winner" test).
Changes
See individual commit messages - I tried to make these as atomic and self-explanatory as possible.
Testing