Skip to content

Commit

Permalink
Merge featurecat#848 yet again for another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Feb 17, 2021
2 parents 4341620 + 294214e commit 4705efb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/featurecat/lizzie/rules/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ public void pass(Stone color, boolean newBranch, boolean dummy, boolean changeMo
Stone[] stones = history.getStones().clone();
Zobrist zobrist = history.getZobrist();
int moveNumber = history.getMoveNumber() + 1;
int moveMNNumber = nextMoveMNNumber(newBranch);
int[] moveNumberList =
newBranch && history.getNext(true).isPresent()
? new int[Board.boardWidth * Board.boardHeight]
Expand All @@ -432,6 +433,7 @@ public void pass(Stone color, boolean newBranch, boolean dummy, boolean changeMo
0.0,
0,
0.0);
newState.moveMNNumber = moveMNNumber;
newState.dummy = dummy;

// update leelaz with pass
Expand All @@ -451,6 +453,12 @@ public void pass() {
pass(history.isBlacksTurn() ? Stone.BLACK : Stone.WHITE);
}

private int nextMoveMNNumber(boolean newBranch) {
boolean isNewSubBranch = newBranch && (history.getCurrentHistoryNode().numberOfChildren() > 0);
boolean isMissingMoveMNNumber = history.getMoveMNNumber() < 0;
return isNewSubBranch ? 1 : isMissingMoveMNNumber ? -1 : history.getMoveMNNumber() + 1;
}

/**
* Places a stone onto the board representation. Thread safe
*
Expand Down Expand Up @@ -519,12 +527,8 @@ public void place(int x, int y, Stone color, boolean newBranch, boolean changeMo
Stone[] stones = history.getStones().clone();
Zobrist zobrist = history.getZobrist();
Optional<int[]> lastMove = Optional.of(new int[] {x, y});
boolean isNewSubBranch =
newBranch && (history.getCurrentHistoryNode().numberOfChildren() > 0);
boolean isMissingMoveMNNumber = history.getMoveMNNumber() < 0;
int moveNumber = history.getMoveNumber() + 1;
int moveMNNumber =
isNewSubBranch ? 1 : isMissingMoveMNNumber ? -1 : history.getMoveMNNumber() + 1;
int moveMNNumber = nextMoveMNNumber(newBranch);
int[] moveNumberList =
newBranch && history.getNext(true).isPresent()
? new int[Board.boardWidth * Board.boardHeight]
Expand Down

0 comments on commit 4705efb

Please sign in to comment.