From 94c5c4837c579bc3ff3af02f86e6cfd49d604a7c Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Thu, 20 Mar 2025 14:00:51 +0900 Subject: [PATCH] =?UTF-8?q?DO-4=20[Feat]=20Omok=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20=EA=B0=80=EB=8A=A5=ED=95=9C=20=EC=8A=B9?= =?UTF-8?q?=ED=8C=A8=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/AI/AIEvaluator.cs | 3 ++- Assets/Script/AI/MiniMaxAIController.cs | 4 +--- Assets/Script/AI/OmokAI.cs | 7 +++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Assets/Script/AI/AIEvaluator.cs b/Assets/Script/AI/AIEvaluator.cs index 3ad13f6..d9855d8 100644 --- a/Assets/Script/AI/AIEvaluator.cs +++ b/Assets/Script/AI/AIEvaluator.cs @@ -243,7 +243,7 @@ public static class AIEvaluator } // 방향이 평행한지 확인하는 함수 - private static bool AreParallelDirections(int[] dir1, int[] dir2) + private static bool AreParallelDirections(int[] dir1, int[] dir2) // Vector로 변경 { return (dir1[0] == dir2[0] && dir1[1] == dir2[1]) || (dir1[0] == -dir2[0] && dir1[1] == -dir2[1]); @@ -320,6 +320,7 @@ public static class AIEvaluator foreach (var dir in Directions) { + // 평가를 위한 가상 보드이기에 캐시 데이터에 저장X var (count, openEnds) = MiniMaxAIController.CountStones(board, row, col, dir, AIPlayer, false); aiPatterns.Add((dir, count, openEnds)); diff --git a/Assets/Script/AI/MiniMaxAIController.cs b/Assets/Script/AI/MiniMaxAIController.cs index 7baa9d4..76e1c74 100644 --- a/Assets/Script/AI/MiniMaxAIController.cs +++ b/Assets/Script/AI/MiniMaxAIController.cs @@ -181,8 +181,6 @@ public static class MiniMaxAIController Enums.PlayerType[,] board, int row, int col, int[] direction, Enums.PlayerType player, bool isSaveInCache = true) { int dirX = direction[0], dirY = direction[1]; - // var key = (row, col, dirX, dirY); - var posKey = (row, col); var dirKey = (dirX, dirY); @@ -271,7 +269,7 @@ public static class MiniMaxAIController #endregion // 최근에 둔 돌 위치 기반으로 게임 승리를 판별하는 함수 - // !!!!!!MinimaxAIController 밖의 cs파일은 호출 시 맨 마지막을 false로 지정해야 합니다.!!!!!! + // MinimaxAIController 밖의 cs파일은 호출 시 맨 마지막을 false로 지정해야 합니다. public static bool CheckGameWin(Enums.PlayerType player, Enums.PlayerType[,] board, int row, int col, bool isSavedCache) { diff --git a/Assets/Script/AI/OmokAI.cs b/Assets/Script/AI/OmokAI.cs index a7e1d3e..883828d 100644 --- a/Assets/Script/AI/OmokAI.cs +++ b/Assets/Script/AI/OmokAI.cs @@ -16,4 +16,11 @@ public class OmokAI : MonoBehaviour (int row, int col)? bestMove = await Task.Run(() => MiniMaxAIController.GetBestMove(board)); callback?.Invoke(bestMove); } + + // true: Win, false: Lose + public bool CheckGameWin(Enums.PlayerType player, Enums.PlayerType[,] board, int row, int col) + { + bool isWin = MiniMaxAIController.CheckGameWin(player, board, row, col, false); + return isWin; + } }