From 99b7f705ea4c8a0dfe266ae086afbbdc8f5d280b Mon Sep 17 00:00:00 2001 From: fiore Date: Thu, 20 Mar 2025 01:07:55 +0900 Subject: [PATCH] =?UTF-8?q?DO-31=20Fix=20:=20=EA=B1=B0=EC=A7=93=20?= =?UTF-8?q?=EA=B8=88=EC=88=98=20=ED=83=90=EC=A7=80=20=EB=B6=88=EA=B0=80=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 거짓금수가 나올 수 있는 금수는 쌍삼 뿐임 - 쌍삼이 감지된 경우 한 수를 더 내다 보고 금수로 막히는 경우 쌍삼아님 --- .../Renju/RenjuForbiddenMoveDetector.cs | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs b/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs index fce9c13..8fe5421 100644 --- a/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs +++ b/Assets/Script/Renju/RenjuForbiddenMoveDetector.cs @@ -18,6 +18,7 @@ public class RenjuForbiddenMoveDetector : ForbiddenDetectorBase { var tempBoard = (Enums.PlayerType[,])board.Clone(); + var forbiddenCount = 0; List forbiddenMoves = new(); for (int row = 0; row < BoardSize; row++) { @@ -29,6 +30,7 @@ public class RenjuForbiddenMoveDetector : ForbiddenDetectorBase // 장목 검사 if (_overlineDetactor.IsOverline(tempBoard, row, col)) { + forbiddenCount++; Debug.Log("장목 금수 좌표 X축 : " + row + ", Y축 : " + col); forbiddenMoves.Add(new Vector2Int(row, col)); continue; @@ -37,20 +39,46 @@ public class RenjuForbiddenMoveDetector : ForbiddenDetectorBase // 4-4 검사 if (_doubleFourDetactor.IsDoubleFour(tempBoard, row, col)) { + forbiddenCount++; Debug.Log("사사 금수 좌표 X축 : " + row + ", Y축 : " + col); forbiddenMoves.Add(new Vector2Int(row, col)); continue; } + if(forbiddenCount >1) continue; + // 3-3 검사 if (_doubleThreeDetector.IsDoubleThree(tempBoard, row, col)) { - Debug.Log("삼삼 금수 좌표 X축 : " + row + ", Y축 : " + col); - forbiddenMoves.Add(new Vector2Int(row, col)); + if (CheckFakeForbiddenMove(tempBoard, row, col)) + { + Debug.Log("삼삼 금수 좌표 X축 : " + row + ", Y축 : " + col); + forbiddenMoves.Add(new Vector2Int(row, col)); + } + } } } 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; + } } \ No newline at end of file