DO-31 Debug: 금수 반환 문제 확인 중
This commit is contained in:
parent
99b7f705ea
commit
d5fdd72ce8
@ -133,7 +133,7 @@ public class RenjuDoubleFourDetector: ForbiddenDetectorBase
|
||||
}
|
||||
else
|
||||
{
|
||||
linePattern[centerIndex + i] = Space; // 범위 밖은 빈칸으로 처리
|
||||
linePattern[centerIndex + i] = White; // 범위 밖은 백돌로 처리
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ public class RenjuDoubleFourDetector: ForbiddenDetectorBase
|
||||
}
|
||||
else
|
||||
{
|
||||
linePattern[centerIndex - i] = Space; // 범위 밖은 빈칸으로 처리
|
||||
linePattern[centerIndex - i] = White; // 범위 밖은 백돌로 처리
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +178,7 @@ public class RenjuDoubleFourDetector: ForbiddenDetectorBase
|
||||
}
|
||||
}
|
||||
|
||||
// 정확히 4개의 돌이 있고, 1개의 빈칸이 있으면 4로 판정
|
||||
// 4개의 돌이 있고, 1개의 빈칸이 있으면 4로 판정
|
||||
// (현재 위치는 흑으로 이미 설정되어 있음)
|
||||
if (stoneCount == 4)
|
||||
{
|
||||
|
@ -1,3 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0daf1f2b8cbe4b19adc0e42db7a15991
|
||||
timeCreated: 1742270734
|
||||
fileFormatVersion: 2
|
||||
guid: f997e95272e950240a6e9e2f8a99fdfa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
@ -18,13 +18,13 @@ public class RenjuDoubleThreeDetector: ForbiddenDetectorBase
|
||||
// 쌍삼 검사
|
||||
bool isDoubleThree = CheckDoubleThree(board, row, col);
|
||||
|
||||
// 쌍삼으로 판정된 경우 4-3 상황인지 추가 검사
|
||||
// 쌍삼으로 판정된 경우
|
||||
if (isDoubleThree)
|
||||
{
|
||||
// 4가 만들어지는지 확인
|
||||
bool hasFour = CheckForFour(board, row, col);
|
||||
|
||||
// 4-3 상황이면 금수에서 제외
|
||||
// 4-3 상황
|
||||
if (hasFour)
|
||||
{
|
||||
isDoubleThree = false;
|
||||
@ -37,6 +37,8 @@ public class RenjuDoubleThreeDetector: ForbiddenDetectorBase
|
||||
return isDoubleThree;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 쌍삼(3-3) 여부를 검사합니다.
|
||||
/// </summary>
|
||||
@ -56,6 +58,7 @@ public class RenjuDoubleThreeDetector: ForbiddenDetectorBase
|
||||
openThreeCount++;
|
||||
|
||||
// 이미 열린 3이 2개 이상 발견되면 쌍삼으로 판정
|
||||
// TODO : 44를 만들 수 있는가??
|
||||
if (openThreeCount >= 2)
|
||||
{
|
||||
return true;
|
||||
@ -119,9 +122,11 @@ public class RenjuDoubleThreeDetector: ForbiddenDetectorBase
|
||||
/// </summary>
|
||||
private bool CheckForOpenThree(Enums.PlayerType[] linePattern, int centerIndex)
|
||||
{
|
||||
|
||||
// 둘다 아니면 열린 3이 아님
|
||||
return CheckConsecutiveOpenThree(linePattern, centerIndex) || // 연속된 열린 3 확인
|
||||
CheckGappedOpenThree(linePattern, centerIndex); // 한 칸 떨어진 열린 3 확인
|
||||
// TODO : 한칸 떨어진 열린 3, 여기서 장목이 되는지 체크해서 배제 해야함
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@ -16,19 +17,19 @@ public class RenjuForbiddenMoveDetector : ForbiddenDetectorBase
|
||||
/// <returns>금수 좌표를 담은 리스트</returns>
|
||||
public List<Vector2Int> RenjuForbiddenMove(Enums.PlayerType[,] board)
|
||||
{
|
||||
var tempBoard = (Enums.PlayerType[,])board.Clone();
|
||||
|
||||
var forbiddenCount = 0;
|
||||
List<Vector2Int> forbiddenMoves = new();
|
||||
List<Vector2Int> tempForbiddenMoves = new();
|
||||
for (int row = 0; row < BoardSize; row++)
|
||||
{
|
||||
for (int col = 0; col < BoardSize; col++)
|
||||
{
|
||||
// ** 비어 있지 않으면 검사할 필요 없음 **
|
||||
if (!IsEmptyPosition(tempBoard, row, col)) continue;
|
||||
if (!IsEmptyPosition(board, row, col)) continue;
|
||||
|
||||
// 장목 검사
|
||||
if (_overlineDetactor.IsOverline(tempBoard, row, col))
|
||||
if (_overlineDetactor.IsOverline(board, row, col))
|
||||
{
|
||||
forbiddenCount++;
|
||||
Debug.Log("장목 금수 좌표 X축 : " + row + ", Y축 : " + col);
|
||||
@ -37,7 +38,7 @@ public class RenjuForbiddenMoveDetector : ForbiddenDetectorBase
|
||||
}
|
||||
|
||||
// 4-4 검사
|
||||
if (_doubleFourDetactor.IsDoubleFour(tempBoard, row, col))
|
||||
if (_doubleFourDetactor.IsDoubleFour(board, row, col))
|
||||
{
|
||||
forbiddenCount++;
|
||||
Debug.Log("사사 금수 좌표 X축 : " + row + ", Y축 : " + col);
|
||||
@ -45,40 +46,91 @@ public class RenjuForbiddenMoveDetector : ForbiddenDetectorBase
|
||||
continue;
|
||||
}
|
||||
|
||||
if(forbiddenCount >1) continue;
|
||||
if(forbiddenCount > 0) continue;
|
||||
|
||||
// 3-3 검사
|
||||
if (_doubleThreeDetector.IsDoubleThree(tempBoard, row, col))
|
||||
if (_doubleThreeDetector.IsDoubleThree(board, row, col))
|
||||
{
|
||||
if (CheckFakeForbiddenMove(tempBoard, row, col))
|
||||
{
|
||||
Debug.Log("삼삼 금수 좌표 X축 : " + row + ", Y축 : " + col);
|
||||
forbiddenMoves.Add(new Vector2Int(row, col));
|
||||
}
|
||||
|
||||
tempForbiddenMoves.Add(new Vector2Int(row, col));
|
||||
// if (!SimulateDoubleFour(tempBoard))
|
||||
// {
|
||||
// Debug.Log("삼삼 금수 좌표 X축 : " + row + ", Y축 : " + col);
|
||||
// forbiddenMoves.Add(new Vector2Int(row, col));
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var pos in tempForbiddenMoves)
|
||||
{
|
||||
board[pos.x, pos.y] = Black;
|
||||
if (!SimulateDoubleFour(board)&& !SimulateOverline(board))
|
||||
{
|
||||
Debug.Log("X: "+pos.x + "Y: "+ pos.y);
|
||||
forbiddenMoves.Add(new Vector2Int(pos.x, pos.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Debug.Log(DebugBoard(board));
|
||||
return forbiddenMoves;
|
||||
}
|
||||
|
||||
private bool CheckFakeForbiddenMove(Enums.PlayerType[,] board, int row, int col)
|
||||
|
||||
|
||||
private bool SimulateDoubleFour(Enums.PlayerType[,] board)
|
||||
{
|
||||
var tempBoard = (Enums.PlayerType[,])board.Clone();
|
||||
tempBoard[row, col] = Black;
|
||||
|
||||
for (int newRow = 0; newRow < BoardSize; newRow++)
|
||||
for (int row = 0; row < BoardSize; row++)
|
||||
{
|
||||
for (int newCol = 0; newCol < BoardSize; newCol++)
|
||||
for (int col = 0; col < BoardSize; col++)
|
||||
{
|
||||
// ** 비어 있지 않으면 검사할 필요 없음 **
|
||||
if (!IsEmptyPosition(tempBoard, newRow, newCol)) continue;
|
||||
|
||||
return _overlineDetactor.IsOverline(tempBoard, newRow, newCol) ||
|
||||
_doubleFourDetactor.IsDoubleFour(tempBoard, newRow, newCol);
|
||||
if (_doubleFourDetactor.IsDoubleFour(board, row, col))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool SimulateOverline(Enums.PlayerType[,] board)
|
||||
{
|
||||
for (int row = 0; row < BoardSize; row++)
|
||||
{
|
||||
for (int col = 0; col < BoardSize; col++)
|
||||
{
|
||||
if (_overlineDetactor.IsOverline(board, row, col))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 보드 상태를 시각적으로 출력하는 디버깅 함수
|
||||
/// </summary>
|
||||
/// <param name="board">현재 보드 상태</param>
|
||||
/// <returns>보드의 시각적 표현 문자열</returns>
|
||||
private string DebugBoard(Enums.PlayerType[,] board)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int row = 0; row < BoardSize; row++)
|
||||
{
|
||||
for (int col = 0; col < BoardSize; col++)
|
||||
{
|
||||
sb.Append(board[row, col] switch
|
||||
{
|
||||
Enums.PlayerType.None => "□",
|
||||
Enums.PlayerType.PlayerA => "●",
|
||||
Enums.PlayerType.PlayerB => "○",
|
||||
_ => "?"
|
||||
});
|
||||
}
|
||||
sb.AppendLine(); // 줄바꿈 추가
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8618553c3e244abdb040fb7378dd4b65
|
||||
timeCreated: 1741939566
|
||||
fileFormatVersion: 2
|
||||
guid: 4440d621b56f2ce459d819497911892b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
Loading…
x
Reference in New Issue
Block a user