Skip to content

Commit

Permalink
Merge pull request #411 from alreadydone/next
Browse files Browse the repository at this point in the history
  • Loading branch information
zsalch committed Nov 3, 2018
2 parents 9257fd3 + 3f54f4e commit a066f38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/featurecat/lizzie/rules/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public void place(int x, int y, Stone color, boolean newBranch) {
0);

// don't make this coordinate if it is suicidal or violates superko
if (isSuicidal > 0 || history.violatesSuperko(newState)) return;
if (isSuicidal > 0 || history.violatesKoRule(newState)) return;

// update leelaz with board position
if (Lizzie.frame.isPlayingAgainstLeelaz
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/featurecat/lizzie/rules/BoardHistoryList.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ public boolean violatesSuperko(BoardData data) {
return false;
}

public boolean violatesKoRule(BoardData data) {
// check if the current position is identical to the position two moves ago
return this.head
.previous()
.map(p -> p != null && data.zobrist.equals(p.getData().zobrist))
.orElse(false);
}

/**
* Returns the root node
*
Expand Down

0 comments on commit a066f38

Please sign in to comment.