コード例 #1
0
ファイル: Data.cs プロジェクト: da-huin/tictactoe-ai
        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);
        }
コード例 #2
0
ファイル: Data.cs プロジェクト: da-huin/tictactoe-ai
        private static void AddKnowledge(nBoard board, nPoint lastPos, char WLD)
        {
            int    listIndex   = 0;
            var    AIBoardList = brain[board.PuttingCount - 1];
            nBoard prevBoard   = new nBoard(board);

            prevBoard[lastPos].player = Players.NULL;

            // 하나 뺀 보드를 주어야 한다.
            bool IsGetted = IsBrainGettedBoard(prevBoard, AIBoardList, out listIndex);


            // 같은 것이 있을 때
            if (IsGetted)
            {
                if (WLD == 'W')
                {
                    AIBoardList[listIndex][lastPos].winCount++;
                }
                else if (WLD == 'L')
                {
                    AIBoardList[listIndex][lastPos].loseCount++;
                }
                else if (WLD == 'D')
                {
                    AIBoardList[listIndex][lastPos].drawCount++;
                }
            }
            // 같은 것이 없을 때
            else
            {
                nAIBoard newAIBoard = new nAIBoard(prevBoard);
                if (WLD == 'W')
                {
                    newAIBoard[lastPos].winCount++;
                }
                else if (WLD == 'L')
                {
                    newAIBoard[lastPos].loseCount++;
                }
                else if (WLD == 'D')
                {
                    newAIBoard[lastPos].drawCount++;
                }

                AIBoardList.Add(newAIBoard);
            }
        }