带记忆的死子判断

main
dai_48k 2024-01-24 11:35:18 +08:00
parent 0b734f3aa7
commit 45dfc21713
1 changed files with 8 additions and 2 deletions

View File

@ -76,9 +76,12 @@ public class CalDataUtil {
Cross obc = cross == Cross.BLACK ? Cross.WHITE : Cross.BLACK;
boolean[][] aliveConfirmed = new boolean[map.length][map.length]; // 已被确认为活棋的区域
for (int i = 0; i < map.length; i++) {
for (int j = 0; j < map.length; j++) {
if (map[i][j] == obc) {
// 为目标色,并且该位置未确认活棋
if (map[i][j] == obc && !aliveConfirmed[i][j]) {
// BFS 查找是否存在 NONE 边界
int len = 0;
List<KVPair> queue = new ArrayList<>();
@ -123,6 +126,9 @@ public class CalDataUtil {
if (isDead) {
// 去除操作
colored.forEach(item -> draw(Cross.NONE, item.k + 1, item.v + 1, map));
} else {
// 确认活棋
colored.forEach(item -> aliveConfirmed[item.k][item.v] = true);
}
}
}
@ -138,7 +144,7 @@ public class CalDataUtil {
return true;
}
// 为己方的,则假如队列,否则对方不进行操作
// 为己方的,则加入队列,否则对方不进行操作
if (map[row][col] == obc) {
queue.add(new KVPair(row, col));
colored.add(new KVPair(row, col));