DO-4 [Feat] Omok에서 호출 가능한 승패 함수 추가
This commit is contained in:
parent
fc321e9cda
commit
94c5c4837c
@ -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]) ||
|
return (dir1[0] == dir2[0] && dir1[1] == dir2[1]) ||
|
||||||
(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)
|
foreach (var dir in Directions)
|
||||||
{
|
{
|
||||||
|
// 평가를 위한 가상 보드이기에 캐시 데이터에 저장X
|
||||||
var (count, openEnds) = MiniMaxAIController.CountStones(board, row, col, dir, AIPlayer, false);
|
var (count, openEnds) = MiniMaxAIController.CountStones(board, row, col, dir, AIPlayer, false);
|
||||||
aiPatterns.Add((dir, count, openEnds));
|
aiPatterns.Add((dir, count, openEnds));
|
||||||
|
|
||||||
|
@ -181,8 +181,6 @@ public static class MiniMaxAIController
|
|||||||
Enums.PlayerType[,] board, int row, int col, int[] direction, Enums.PlayerType player, bool isSaveInCache = true)
|
Enums.PlayerType[,] board, int row, int col, int[] direction, Enums.PlayerType player, bool isSaveInCache = true)
|
||||||
{
|
{
|
||||||
int dirX = direction[0], dirY = direction[1];
|
int dirX = direction[0], dirY = direction[1];
|
||||||
// var key = (row, col, dirX, dirY);
|
|
||||||
|
|
||||||
var posKey = (row, col);
|
var posKey = (row, col);
|
||||||
var dirKey = (dirX, dirY);
|
var dirKey = (dirX, dirY);
|
||||||
|
|
||||||
@ -271,7 +269,7 @@ public static class MiniMaxAIController
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// 최근에 둔 돌 위치 기반으로 게임 승리를 판별하는 함수
|
// 최근에 둔 돌 위치 기반으로 게임 승리를 판별하는 함수
|
||||||
// !!!!!!MinimaxAIController 밖의 cs파일은 호출 시 맨 마지막을 false로 지정해야 합니다.!!!!!!
|
// MinimaxAIController 밖의 cs파일은 호출 시 맨 마지막을 false로 지정해야 합니다.
|
||||||
public static bool CheckGameWin(Enums.PlayerType player, Enums.PlayerType[,] board,
|
public static bool CheckGameWin(Enums.PlayerType player, Enums.PlayerType[,] board,
|
||||||
int row, int col, bool isSavedCache)
|
int row, int col, bool isSavedCache)
|
||||||
{
|
{
|
||||||
|
@ -16,4 +16,11 @@ public class OmokAI : MonoBehaviour
|
|||||||
(int row, int col)? bestMove = await Task.Run(() => MiniMaxAIController.GetBestMove(board));
|
(int row, int col)? bestMove = await Task.Run(() => MiniMaxAIController.GetBestMove(board));
|
||||||
callback?.Invoke(bestMove);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user