Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
featurecat committed Jun 7, 2020
2 parents 68784e5 + 6432172 commit aa7a276
Show file tree
Hide file tree
Showing 5 changed files with 453 additions and 426 deletions.
22 changes: 19 additions & 3 deletions src/main/java/featurecat/lizzie/analysis/Leelaz.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class Leelaz {
private int cmdNumber;
private int currentCmdNum;
private ArrayDeque<String> cmdQueue;
private boolean isModifyingBoard = false;

private Process process;

Expand Down Expand Up @@ -305,7 +306,7 @@ private void parseLine(String line) {
switching = false;
// Display engine command in the title
Lizzie.frame.updateTitle();
if (isResponseUpToDate()) {
if (isAnalysisUpToDate()) {
// This should not be stale data when the command number match
if (isKataGo) {
this.bestMoves = parseInfoKatago(line.substring(5));
Expand Down Expand Up @@ -537,6 +538,22 @@ private boolean isResponseUpToDate() {
return currentCmdNum >= cmdNumber - 1;
}

private boolean isAnalysisUpToDate() {
return !isModifyingBoard && isResponseUpToDate();
}

public void beginModifyingBoard() {
synchronized (this) {
isModifyingBoard = true;
}
}

public void endModifyingBoard() {
synchronized (this) {
isModifyingBoard = false;
}
}

/**
* @param color color of stone to play
* @param move coordinate of the coordinate
Expand Down Expand Up @@ -692,8 +709,7 @@ public void togglePonder() {

/** End the process */
public void shutdown() {
if (process != null)
process.destroy();
if (process != null) process.destroy();
}

public List<MoveData> getBestMoves() {
Expand Down
Loading

0 comments on commit aa7a276

Please sign in to comment.