Skip to content

Commit

Permalink
Fix capture counting when analyzing a finished game
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Jun 29, 2024
1 parent 4d74948 commit a7ecf71
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/engine/GobanEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1445,14 +1445,16 @@ export class GobanEngine extends BoardState {
ret.white.prisoners = this.white_prisoners;
ret.black.prisoners = this.black_prisoners;

for (let y = 0; y < this.height; ++y) {
for (let x = 0; x < this.width; ++x) {
if (this.removal[y][x]) {
if (this.board[y][x] === JGOFNumericPlayerColor.BLACK) {
ret.white.prisoners += 1;
}
if (this.board[y][x] === JGOFNumericPlayerColor.WHITE) {
ret.black.prisoners += 1;
if (this._cur_move === this.last_official_move) {
for (let y = 0; y < this.height; ++y) {
for (let x = 0; x < this.width; ++x) {
if (this.removal[y][x]) {
if (this.board[y][x] === JGOFNumericPlayerColor.BLACK) {
ret.white.prisoners += 1;
}
if (this.board[y][x] === JGOFNumericPlayerColor.WHITE) {
ret.black.prisoners += 1;
}
}
}
}
Expand Down

0 comments on commit a7ecf71

Please sign in to comment.