Question: Implement the two methods static int evaluateMove8(char [] squares, int squareNumber) { } and static Move bestMove8(char [] squares) { } that do the following:
![Implement the two methods static int evaluateMove8(char [] squares, int squareNumber)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3b6a48cebe_03666f3b6a42cc7a.jpg)
Implement the two methods static int evaluateMove8(char [] squares, int squareNumber) { } and static Move bestMove8(char [] squares) { } that do the following: evaluateMove8 sets the square at index squareNumber to 'O' then sets a temporary variable int value to -1, 0 or 1, depending on whether this move is ultimately a win for O, a draw, or a win for X. To determine which outcome applies, first call boardValue as in exercise 00299. If the return value of that method is 1 or -1 then there is an immediate win for X (value = 1) or O (value = -1). If the return value is 0, then there is no immediate win and we must call bestMove9(board) (which is available to you) to see what X's best response is. In this case, you should set value to the value of that move. Finally, set the square that you changed earlier to 'O' back to a dash ('-') and return value. bestMove8 should loop through the squares and, for each dash found (there will be two), call evaluateMove8 to get the value of moving to that square. Return a Move object whose square and value correspond to the better of the two moves. If both moves have the same value, then return the move associated with the smaller square number. (That just means loop through the squares in forward order and only update the best move if you find a better value) The purpose of bestMove8 () is to find the best move for O when the board already has seven squares filled. The tester tests your bestMove8 () and indirectly tests your evaluateMove8 (), since your bestMove8 () calls evaluateMove8 ()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
