示例#1
0
        protected static List <nPiece[]> GetCliffLine(nBoard board)
        {
            List <nPiece[]> cliffLineArrList = new List <nPiece[]>();

            Tool.DoTicTacToeArray((x, y) =>
            {
                nPiece[] lineArr;
                for (int i = 0; i < 3; i++)
                {
                    lineArr = GetLine(board, i, 'X');
                    if (IsThisLineCliff(lineArr))
                    {
                        cliffLineArrList.Add(lineArr);
                    }
                    lineArr = GetLine(board, i, 'Y');
                    if (IsThisLineCliff(lineArr))
                    {
                        cliffLineArrList.Add(lineArr);
                    }
                    if (i < 2)
                    {
                        lineArr = GetLine(board, i, 'D');
                        if (IsThisLineCliff(lineArr))
                        {
                            cliffLineArrList.Add(lineArr);
                        }
                    }
                }
                return(true);
            });

            return(cliffLineArrList);
        }
示例#2
0
 public nBoard()
 {
     Tool.DoTicTacToeArray((x, y) =>
     {
         pieces[x, y]          = new nPiece();
         pieces[x, y].position = new nPoint(x, y);
         pieces[x, y].player   = Players.NULL;
         return(true);
     });
 }
示例#3
0
 public nAIBoard(nBoard board)
 {
     Tool.DoTicTacToeArray((x, y) =>
     {
         nBoard newBoard        = new nBoard(board);
         AIPieceArr[x, y]       = new nAIPiece();
         AIPieceArr[x, y].piece = newBoard[x, y];
         return(true);
     });
 }
示例#4
0
        private static nBoard AIBoardToBoard(nAIBoard aiBoard)
        {
            nBoard newBoard = new nBoard();

            Tool.DoTicTacToeArray((x, y) =>
            {
                newBoard.pieces[x, y] = aiBoard[x, y].piece;
                return(true);
            });
            return(newBoard);
        }
示例#5
0
        /// <summary>
        /// 다음 수를 AI가 선택해서 포지션을 반환합니다.
        /// </summary>
        /// <param name="board"></param>
        /// <returns></returns>
        public static nPoint GetPutNextPosition(nBoard board)
        {
            if (IsSameLineExist(board))
            {
                return(null);
            }
            if (Tool.IsFullBoard(board))
            {
                return(null);
            }
            // board에서 게임 끝날 라인이 있는지 확인한다.

            var AIBoardList = brain[board.PuttingCount];
            int listIndex   = 0;

            nPoint putPos;

            putPos = GetCliffPos(board, Game.GetCurrentTurn());

            if (putPos == null)
            {    // 이 보드를 가지고 있다면?
                if (IsBrainGettedBoard(board, AIBoardList, out listIndex))
                {
                    // 최고의 승률 포지션 구하기
                    float  bestWinAverage    = 0;
                    nPoint bestWinAveragePos = new nPoint();
                    Tool.DoTicTacToeArray((x, y) =>
                    {
                        if (board[x, y].player != Players.NULL)
                        {
                            return(true);
                        }

                        float nowWinAverage = AIBoardList[listIndex][x, y].WinAverage;
                        if (nowWinAverage >= bestWinAverage)
                        {
                            bestWinAverage      = nowWinAverage;
                            bestWinAveragePos.x = x;
                            bestWinAveragePos.y = y;
                        }
                        return(true);
                    });

                    putPos = bestWinAveragePos;
                }
                else
                {
                    putPos = GetAnyVoidPos(board);
                }
            }

            return(putPos);
        }
示例#6
0
        public nBoard(nBoard board)
        {
            Tool.DoTicTacToeArray((x, y) =>
            {
                pieces[x, y]          = new nPiece();
                pieces[x, y].position = new nPoint(x, y);
                pieces[x, y].player   = board[x, y].player;


                lastPutPosition = new nPoint(board.lastPutPosition.x, board.lastPutPosition.y);
                return(true);
            });
        }
示例#7
0
        protected static List <nPoint> GetVoidPosList(nBoard board)
        {
            List <nPoint> posList = new List <nPoint>();

            Tool.DoTicTacToeArray((x, y) =>
            {
                if (board[x, y].player == Players.NULL)
                {
                    posList.Add(new nPoint(x, y));
                }
                return(true);
            });
            return(posList);
        }