From 3da0ef33f0650fb07866b7f862a63be6e8bfe375 Mon Sep 17 00:00:00 2001 From: Sehyeon Date: Thu, 20 Mar 2025 16:23:45 +0900 Subject: [PATCH] =?UTF-8?q?DO-4=20[Fix]=20GameLogic=EC=9D=98=20SinglePlay?= =?UTF-8?q?=20=EC=8B=9C=20secondPlayerState=EB=A5=BC=20AI=EB=A1=9C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Script/Game/GameLogic.cs | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/Assets/Script/Game/GameLogic.cs b/Assets/Script/Game/GameLogic.cs index 2dd2064..37aac6e 100644 --- a/Assets/Script/Game/GameLogic.cs +++ b/Assets/Script/Game/GameLogic.cs @@ -86,6 +86,11 @@ public class AIState: BasePlayerState { gameLogic.fioTimer.StartTimer(); //TODO: AI이식 + OmokAI.Instance.StartBestMoveSearch(gameLogic.GetBoard(), (bestMove) => + { + if(bestMove.HasValue) + HandleMove(gameLogic, bestMove.Value.Item1, bestMove.Value.Item2); + }); } public override void OnExit(GameLogic gameLogic) @@ -210,7 +215,7 @@ public class GameLogic : MonoBehaviour { case Enums.GameType.SinglePlay: firstPlayerState = new PlayerState(true); - secondPlayerState = new PlayerState(false); + secondPlayerState = new AIState(); SetState(firstPlayerState); break; case Enums.GameType.MultiPlay: @@ -221,6 +226,12 @@ public class GameLogic : MonoBehaviour break; } } + + public Enums.PlayerType[,] GetBoard() + { + return _board; + } + //착수 버튼 클릭시 호출되는 함수 public void OnConfirm() { @@ -282,24 +293,6 @@ public class GameLogic : MonoBehaviour ReplayManager.Instance.RecordStonePlaced(Enums.StoneType.Black, row, col); //기보 데이터 저장 break; case Enums.PlayerType.PlayerB: - /* - // AI 테스트 시작 - OmokAI.Instance.StartBestMoveSearch(_board, (bestMove) => - { - if (bestMove != null) - { - // 타이머 제대로 30초로 clear안되는 문제. 아마 스레드가 언제 끝나는 지 몰라서 그러는 듯 - stoneController.SetStoneType(Enums.StoneType.White, bestMove.Value.Item1, bestMove.Value.Item2); - stoneController.SetStoneState(Enums.StoneState.LastPositioned, bestMove.Value.Item1, bestMove.Value.Item2); - _board[bestMove.Value.Item1, bestMove.Value.Item2] = Enums.PlayerType.PlayerB; - LastNSelectedSetting(bestMove.Value.Item1, bestMove.Value.Item2); - - ReplayManager.Instance.RecordStonePlaced(Enums.StoneType.White, bestMove.Value.Item1, bestMove.Value.Item2); - } - }); - // AI 테스트 끝 - */ - stoneController.SetStoneType(Enums.StoneType.White, row, col); stoneController.SetStoneState(Enums.StoneState.LastPositioned, row, col); _board[row, col] = Enums.PlayerType.PlayerB;