Skip to content

Commit

Permalink
Add autoscore test case
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Jun 19, 2024
1 parent 1e83e3c commit 27da7f0
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/engine/autoscore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,15 @@ export function autoscore(

const avg = total_ownership / group.intersections.length;

// If we meet our sealing threshold, seal
if (avg <= WHITE_SEAL_THRESHOLD || avg >= BLACK_SEAL_THRESHOLD) {
const color =
avg <= WHITE_SEAL_THRESHOLD
? JGOFNumericPlayerColor.WHITE
: JGOFNumericPlayerColor.BLACK;

// For each point, if it's touching a stone of the other color, mark it
// as a seal point.
group.map((point) => {
const x = point.x;
const y = point.y;
Expand Down
63 changes: 63 additions & 0 deletions test/autoscore_test_files/game_dev_51750014.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"game_id": 51750014,
"board": [
" b WWWWWWW W",
"W W WWbWbW ",
"WWW WbbbbbWb",
"WbbWW b b ",
"b b WW ",
" bb W b bb",
" b W bW",
" b bW b bWW",
" bWW bWW",
" bbW bbW ",
" bWbbbbWWb",
" bWWWWWWWW",
" bWWW "
],
"black": [
[-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0],
[-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -0.1],
[-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0],
[-1.0, 1.0, 1.0, -1.0, -1.0, -0.6, -0.1, -0.1, 0.5, 1.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.0, -0.9, -1.0, -1.0, -0.7, -0.5, 0.0, 1.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, -0.2, -1.0, -0.5, 1.0, 1.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, -0.2, -1.0, 0.1, 0.5, 0.8, 1.0, 1.0, -1.0],
[1.0, 1.0, 1.0, 1.0, 0.7, 0.8, -1.0, -0.4, 1.0, 0.9, 1.0, -1.0, -1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -0.1, 0.2, 0.7, 1.0, -1.0, -1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -0.4, 0.1, 0.5, 1.0, 1.0, -1.0, -1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0],
[1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]
],
"white": [
[-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0],
[-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -0.1],
[-1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0],
[-1.0, 1.0, 1.0, -1.0, -1.0, -0.6, -0.1, 0.1, 0.5, 1.0, 1.0, 1.0, 1.0],
[0.9, 0.9, 1.0, -0.6, -1.0, -1.0, -0.5, -0.1, 0.1, 1.0, 1.0, 1.0, 1.0],
[0.9, 0.9, 1.0, 1.0, 1.0, -0.3, -1.0, -0.4, 1.0, 0.9, 1.0, 1.0, 1.0],
[0.9, 1.0, 1.0, 1.0, 1.0, -0.3, -1.0, -0.0, 0.5, 1.0, 1.0, 1.0, -1.0],
[1.0, 1.0, 1.0, 1.0, 0.7, 0.8, -1.0, -0.3, 1.0, 0.9, 1.0, -1.0, -1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -0.2, -0.0, 0.6, 1.0, -1.0, -1.0],
[1.0, 1.0, 0.9, 1.0, 1.0, -1.0, -0.5, 0.0, 0.5, 1.0, 1.0, -1.0, -1.0],
[0.9, 0.9, 0.9, 0.6, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0],
[0.7, 0.9, 0.6, -0.9, 1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0],
[0.0, -0.6, -0.9, -0.9, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]
],
"correct_ownership": [
"WWWWWWWWWWWWW",
"WWWWWWWWBWBW ",
"WWWWWWBBBBBWB",
"WBBWWs** B B ",
"BBB WWs** ",
"BBBBB WsB BB",
"BBBBB Ws* BW",
"BBBBBBWsB BWW",
"BBBBBWWs* BWW",
"BBBBBWs**BBWW",
"BBBBBWBBBBWWW",
"BBBBBWWWWWWWW",
"BBBBWWWWWWWWW"
]
}

0 comments on commit 27da7f0

Please sign in to comment.