The Computer Move
Learn how to generate the computer's move.
We'll cover the following...
What we have
We have created a function to place player’s moves on the board. Here is the snap of the getMove()
function, which calls the getComputerMove()
function.
Press + to interact
int getMove(char board[], int mode, char currentPlayer) {int move;if (mode == 1 && currentPlayer == 'O') {move = getComputerMove(board);cout << "Computer chose: " << move << "\n";}else {move = getUserMove(currentPlayer, board);}return move;}
Here is the getComputerMove()
function that simply calls the randomMove()
function as shown below:
Press + to interact
int getComputerMove(char board[]) {int move;move = randomMove(board);return move;}
We can ...