Skip to content
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

Allow moves violating superko to be played; only enforce basic ko rule #411

Merged
merged 3 commits into from
Nov 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/featurecat/lizzie/rules/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

public class Board implements LeelazListener {
public static int boardSize = Lizzie.config.config.getJSONObject("ui").optInt("board-size", 19);
public static int BOARD_SIZE = boardSize;
private static final String alphabet = "ABCDEFGHJKLMNOPQRST";

private BoardHistoryList history;
Expand Down Expand Up @@ -398,7 +399,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
6 changes: 6 additions & 0 deletions src/main/java/featurecat/lizzie/rules/BoardHistoryList.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ public boolean violatesSuperko(BoardData data) {
return false;
}

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

/**
* Returns the root node
*
Expand Down