Skip to content

Commit

Permalink
Merge featurecat#782 yet again for another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed May 10, 2022
2 parents 61d4c58 + 2ce1d7f commit c293dd9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/featurecat/lizzie/rules/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import featurecat.lizzie.analysis.Leelaz;
import featurecat.lizzie.analysis.LeelazListener;
import featurecat.lizzie.analysis.MoveData;
import featurecat.lizzie.util.Utils;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
Expand All @@ -22,6 +23,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.json.JSONException;

public class Board implements LeelazListener {
Expand Down Expand Up @@ -1476,6 +1478,11 @@ public void toggleAnalysis() {
}

public void bestMoveNotification(List<MoveData> bestMoves) {
SwingUtilities.invokeLater(() -> bestMoveNotificationInEDT(bestMoves));
}

private void bestMoveNotificationInEDT(List<MoveData> bestMoves) {
Utils.mustBeEventDispatchThread();
if (analysisMode) {
boolean isSuccessivePass =
(history.getPrevious().isPresent()
Expand All @@ -1496,6 +1503,10 @@ public void bestMoveNotification(List<MoveData> bestMoves) {
sum += move.playouts;
}
if (sum >= playoutsAnalysis) {
// We need to call this "nextMove()" in EDT.
// Otherwise, it can flip history.isBlacksTurn() BEFORE
// drawEstimateRectKataInEDT().
// Then the ownerships are drawn with wrong colors.
nextMove();
}
}
Expand Down

0 comments on commit c293dd9

Please sign in to comment.