diff --git a/TicTacToeEx/T3EBoard.cpp b/TicTacToeEx/T3EBoard.cpp index 1e20b04..40da3fe 100644 --- a/TicTacToeEx/T3EBoard.cpp +++ b/TicTacToeEx/T3EBoard.cpp @@ -104,6 +104,7 @@ return place; } + // ��莞 else { best = INT_MAX; @@ -129,11 +130,32 @@ } } } + //����̃~�X��U�����ԉ҂�1 + if (best == 1) { + for (int i = 0; i < BOARD_SIZE; i++) { + if (m_Board[i] == 0) { + for (int j = 0; j < BOARD_SIZE; j++) { + NextBoard[j] = m_Board[j]; + } + SetStone(NextBoard, i, PLAYER1, m_Turn + 1); + if (CheckWin(NextBoard) == 1)return i; + } + } + } + + //����̃~�X��U�����ԉ҂��Q + if (m_Turn == 1) { + if (m_Board[1] == 1)return 8; + if (m_Board[3] == 1)return 8; + if (m_Board[5] == 1)return 0; + if (m_Board[7] == 1)return 0; + + } + std::cout << "CPU => " << place << std::endl; return place; } - printf("���肦�Ȃ��Ƃ͂��������Ǘ����ŏꏊ���߂܂�\n"); do { place = rand() % BOARD_SIZE; } while (m_Board[place] != NONE); @@ -292,6 +314,7 @@ return Count; } + //�΂�u�� //�����Fint *Board �ǖ�, int place�@�u���ꏊ, int NextPlayer ���u���l, int turn �^�[���� void T3EBoard::SetStone(int *Board, int place, int NextPlayer, int Turn) {