3.3 Class Evaluate This class implements all the auxiliary methods needed by the algorithm that plays...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
An inverted pyramidal tank has an equilateral triangular base measuring 3 ft. on a side and an altitude of 7 ft. DSMIT adi a. How many gallons of water can the tank hold? b. What will be the wetted...
-
Superior Drive-Ins Ltd. borrowed money by issuing $1,000,000 of 7% bonds payable at 96.5 on July 1, 2016. The bonds are 10-year bonds and pay interest each January 1 and July 1. 1. How much cash did...
-
During the current year, Rayon Corporation disposed of two different assets. On January 1, prior to their disposal, the accounts reflected the following: Asset Machine A Machine B Original Cost...
-
How to draft a demurrer?
-
On December 1, 2014, Fullerton Company had the following account balances. During December, the company completed the following transactions. Dec. 7 Received $3,600 cash from customers in payment of...
-
Limits Finding limits numerically. Complete the table and use the result to estimate the limit. x-4 80. lim 2 x+4x-3x-4 3.9 3.99 3.999 4.001 4.01 4.1 f(x) 81. lim 4-x-3 x115 x+5 X f(x) -5.1 -5.01...
-
This problem continues the process of preparing the Kipley Company's Employee Payroll Register for the pay period ending January 8th, 20--. In previous chapters, gross wages were computed for each...
-
Describe the role played by the Small Manufacturing Enterprises in the economic development of a country.
-
Fleet Street Incorporated a manufacturer of high-fashion clothing for women, is located in South London in the UK. Its product line consists of trousers (35%), skirts (40%), dresses (15%), and other...
-
Given the following data answer the question. Net Realizable Item Cost Value (NRV) Jokers $3,000 $3,150 Penguins 7,500 7,425 Riddlers 6,600 6,938 Scarecrows 4,800 5,745 (a) Determine the LCNRV for...
-
Create stored procedure which calls a function within using the steps below: Create stored procedure get_Amount() with 3 input parameters - CustomerID, OrderNumber and ProductNumber. Use the...
-
Ramico Limited manufactures a variety of bicycle parts. Since the company produces a large volume of each type of product, the unit cost is determined by a process costing system. The Moulding...
-
Calculate the impact of Controlled Foreign Company ( CFC ) rules on a U . S . parent company with subsidiaries in low - tax jurisdictions reporting combined profits of $ 5 million.
-
Valdez Company is considering eliminating its kitchen division, which reported an operating loss of $60,000 for the past year as shown below. Segment Income (Loss) Sales Variable costs Contribution...
-
Outline some of the major problems confronting an international advertiser.
-
Ken paid the following amounts for interest during 2012: Qualified interest on home mortgage...........................................$4,700 Auto loan...
-
David and Darlene Jasper have one child, Sam, who is 6 years old. The Jaspers reside at 4639 Honeysuckle Lane, Los Angeles, CA 90248. David's Social Security number is 577-11-3311, Darlene's is...
-
Cypress Corporation has regular taxable income of $170,000 (assume annual gross receipts are greater than $5 million) and regular tax liability of $49,550 for 2012. The corporation also has tax...
-
The following table is a life table, reproduced from the chapter introduction. With an understanding of some basic concepts of probability, one can use the life table to compute the probability that...
-
In Example 5.4, what is the probability that the oldest child and the youngest child are of the same gender? Example 5.4 Computing probabilities A family has three children. Denoting a boy by B and a...
-
A quiz consists of three truefalse questions and two multiple-choice questions with five choices each. How many different sets of answers are there?
Study smarter with the SolutionInn App