DO-31 Fix : 거짓 금수 탐지 불가 문제 수정

- 거짓금수가 나올 수 있는 금수는 쌍삼 뿐임
- 쌍삼이 감지된 경우 한 수를 더 내다 보고 금수로 막히는 경우 쌍삼아님
This commit is contained in:
fiore 2025-03-20 01:07:55 +09:00
parent 7b8db4a2f3
commit 99b7f705ea

View File

@ -18,6 +18,7 @@ public class RenjuForbiddenMoveDetector : ForbiddenDetectorBase
{ {
var tempBoard = (Enums.PlayerType[,])board.Clone(); var tempBoard = (Enums.PlayerType[,])board.Clone();
var forbiddenCount = 0;
List<Vector2Int> forbiddenMoves = new(); List<Vector2Int> forbiddenMoves = new();
for (int row = 0; row < BoardSize; row++) for (int row = 0; row < BoardSize; row++)
{ {
@ -29,6 +30,7 @@ public class RenjuForbiddenMoveDetector : ForbiddenDetectorBase
// 장목 검사 // 장목 검사
if (_overlineDetactor.IsOverline(tempBoard, row, col)) if (_overlineDetactor.IsOverline(tempBoard, row, col))
{ {
forbiddenCount++;
Debug.Log("장목 금수 좌표 X축 : " + row + ", Y축 : " + col); Debug.Log("장목 금수 좌표 X축 : " + row + ", Y축 : " + col);
forbiddenMoves.Add(new Vector2Int(row, col)); forbiddenMoves.Add(new Vector2Int(row, col));
continue; continue;
@ -37,20 +39,46 @@ public class RenjuForbiddenMoveDetector : ForbiddenDetectorBase
// 4-4 검사 // 4-4 검사
if (_doubleFourDetactor.IsDoubleFour(tempBoard, row, col)) if (_doubleFourDetactor.IsDoubleFour(tempBoard, row, col))
{ {
forbiddenCount++;
Debug.Log("사사 금수 좌표 X축 : " + row + ", Y축 : " + col); Debug.Log("사사 금수 좌표 X축 : " + row + ", Y축 : " + col);
forbiddenMoves.Add(new Vector2Int(row, col)); forbiddenMoves.Add(new Vector2Int(row, col));
continue; continue;
} }
if(forbiddenCount >1) continue;
// 3-3 검사 // 3-3 검사
if (_doubleThreeDetector.IsDoubleThree(tempBoard, row, col)) if (_doubleThreeDetector.IsDoubleThree(tempBoard, row, col))
{ {
Debug.Log("삼삼 금수 좌표 X축 : " + row + ", Y축 : " + col); if (CheckFakeForbiddenMove(tempBoard, row, col))
forbiddenMoves.Add(new Vector2Int(row, col)); {
Debug.Log("삼삼 금수 좌표 X축 : " + row + ", Y축 : " + col);
forbiddenMoves.Add(new Vector2Int(row, col));
}
} }
} }
} }
return forbiddenMoves; return forbiddenMoves;
} }
private bool CheckFakeForbiddenMove(Enums.PlayerType[,] board, int row, int col)
{
var tempBoard = (Enums.PlayerType[,])board.Clone();
tempBoard[row, col] = Black;
for (int newRow = 0; newRow < BoardSize; newRow++)
{
for (int newCol = 0; newCol < BoardSize; newCol++)
{
// ** 비어 있지 않으면 검사할 필요 없음 **
if (!IsEmptyPosition(tempBoard, newRow, newCol)) continue;
return _overlineDetactor.IsOverline(tempBoard, newRow, newCol) ||
_doubleFourDetactor.IsDoubleFour(tempBoard, newRow, newCol);
}
}
return false;
}
} }