Hello, for the last question about the tictactoe game, I didn't see these methods written in the TicTacToe and AIPlayer classes
Missing in TicTacToe:
A public method named countBlanks which takes no arguments and returns the number of spaces on the board which are blank (the underscore character) as an int.
A public method named markerForPlayer which takes a single Player argument and returns the character representing that player's symbol (either 'X' or 'O', the case where the argument is not one of these players will not be tested).
A public method named checkLose which takes a single Player argument and returns true if the other player is the winner of this board and false otherwise. Note that neither player may be the winner of a given board, either because the game is not over, or because the game is a draw.
Missing in AIPlayer:
It should have two mutually recursive methods, minValue and maxValue. If regular recursion is when a method calls itself, then mutual recursion is when method A calls method B, and method B calls method A. In this case, the recursive calls in minValue will be to maxValue, and the recursive calls in maxValue will be to minValue. The details of how these methods work are as follows:
Both methods are public, take a TicTacToe instance as their single argument, and return a double value.
The base cases for both methods are the same: if the argument represents a tic-tac-toe game where this AIPlayer has won the game the return value is 1.0. If the argument is a game where this player has lost the game the return value is -1.0. If the argument is a draw game, the return value is 0.0. If no one has won and the game is not a draw, the return value of the board must be computed recursively.
The recursive cases are similar to each other, but slightly different. The maxValue method is used to determine what value this player could get by choosing optimally among the options provided by possibleMoves for the current game board. In order to compute this, the AIPlayer assumes that its opponent is going to try and choose the move option on the next board which minimizes its return. Therefore, maxValue should compute the minValue of each of the possible moves for this player, and then return the value of the option with the highest value.
Similarly, the recursive case for the minValue method looks at the possibleMoves for the opponent, computes the maxValue of each option, and returns the value of the option which is lowest.
Whoever provided the java code for the tictactoe game could you please modify it to include the missing methods for the classes above?