Question: 3.3 Class Evaluate This class implements all the auxiliary methods needed by the algorithm that plays the game. For details on the algorithm that

3.3 Class Evaluate This class implements all the auxiliary methods needed bythe algorithm that plays the game. For details on the algorithm that

3.3 Class Evaluate This class implements all the auxiliary methods needed by the algorithm that plays the game. For details on the algorithm that plays the game, please read document Optional Info.pdf posted in OWL as an optional reading for this assignment. The constructor for this class must be as follows public Evaluate (int size, int tilesToWin, int maxLevels) The first parameter specifies the size of the board, the second parameter is the number of adjacent tiles needed to win the game, and the last parameter specifies the playing quality of the program (the higher this value is the better the program will play, but the slower it will be; when you test your program use values between 3 and 5 for this parameter so the program plays OK but it is not too slow). This class must have an instance variable called gameBoard of type char [] [] to store the board. This variable is initialized inside the constructor so that every entry of gameBoard stores the character 'e' indicating that every position of the board is empty. As the game is played, every entry of gameBoard will store one of the characters 'c', 'h', 'e', or 'u'. This class must also implement the following public methods. public Dictionary createDictionary(): returns an empty Dictionary of the size that you have selected. Remember that the size of the dictionary must be a prime number. public Record repeatedState (Dictionary dict): This method first represents the content of the two dimensional array gameBoard as a string as described in Section 2; then it checks whether there is a record in dict with this string as key attribute: If there is, this method returns the Record object that contains it; otherwise the method returns the value null. public void insertState (Dictionary dict, int score, int level): This method first represents the content of gameBoard as a string as described in Section 2, then it creates an object of the class Record storing this string, score, and level; finally, this Record object is stored in dict. Remember that the hash table cannot store two records with the same key attribute. public void storePlay (int row, int col, char symbol): This method stores symbol in gameBoard [row] [col]. public boolean squareIsEmpty (int row, int col): This method returns true if gameBoard [row] [col] is 'e'; otherwise it returns false. public boolean tileOfComputer (int row, int col): gameBoard [row] [col] is 'c'; otherwise it returns false. This method returns true if public boolean tileOfHuman (int row, int col): Returns true if gameBoard [row] [col] is 'h'; otherwise it returns false. public boolean wins (char symbol): Returns true if there are the required number of ad- jacent tiles of type symbol in the same row, column, or diagonal of gameBoard; otherwise it returns false. public boolean isDraw(): Returns true if there are no empty positions left in gameBoard; otherwise it returns false. public int evalBoard(): Returns one of the following values: 3, if the computer has won, i.e. there are the required number of adjacent 'c's in the same row, column, or diagonal of gameBoard. 0, if the human player has won, i.e. there are the required number of adjacent 'h's in the same row, column, or diagonal of gameBoard. 2, if the game is a draw. 1, if the game is still undecided, i.e. no player has won and the game is not a draw. You can implement more methods in this class, if you want, but they must be declared as private.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!