if you have a method that can rate a board to tell you how good or...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
if you have a method that can rate a board to tell you how good or bad it is, you can actually find the best possible move for your Tetris brain using "brute force". In other words, you can try dropping the piece in each possible position and see which option would produce the best outcome, and then use that as your move. Remember that each piece can be rotated, so you actually want to explore each possible rotation of the piece, in each possible drop position. The logic for this looks like: • For each possible rotation of the piece, try: • For each possible column (remember to account for the width of the piece, so you . don't go out of bounds), try: Determine where the piece would land, if dropped in that column (using the appropriate method on the Board) • Place the piece in that position (using the appropriate method on the Board) • Clear any rows that were filled (using the appropriate method on the Board) • Calculate the score for this possible move, using your rateBoard() method • Undo the changes While going through this process, you will need to remember the best move you've come across, so you can return it at the end. The requirements for your bestMove method are: • It must try all rotations of the piece in every position. • It must return a move with a location that is below the specified heightLimit. The limit reserved a certain portion at the top of the board for adding new pieces. It must return a valid move--one where the piece will remain within the board and will not overlap any existing blocks. Tip: you can use the return value of place() to determine which piece locations are not valid. • It must return the valid move with the best (lowest) rateBoard() score, as determined by your rateBoard() method. The move's stored score value should be the one from rateBoard(). if you have a method that can rate a board to tell you how good or bad it is, you can actually find the best possible move for your Tetris brain using "brute force". In other words, you can try dropping the piece in each possible position and see which option would produce the best outcome, and then use that as your move. Remember that each piece can be rotated, so you actually want to explore each possible rotation of the piece, in each possible drop position. The logic for this looks like: • For each possible rotation of the piece, try: • For each possible column (remember to account for the width of the piece, so you . don't go out of bounds), try: Determine where the piece would land, if dropped in that column (using the appropriate method on the Board) • Place the piece in that position (using the appropriate method on the Board) • Clear any rows that were filled (using the appropriate method on the Board) • Calculate the score for this possible move, using your rateBoard() method • Undo the changes While going through this process, you will need to remember the best move you've come across, so you can return it at the end. The requirements for your bestMove method are: • It must try all rotations of the piece in every position. • It must return a move with a location that is below the specified heightLimit. The limit reserved a certain portion at the top of the board for adding new pieces. It must return a valid move--one where the piece will remain within the board and will not overlap any existing blocks. Tip: you can use the return value of place() to determine which piece locations are not valid. • It must return the valid move with the best (lowest) rateBoard() score, as determined by your rateBoard() method. The move's stored score value should be the one from rateBoard().
Expert Answer:
Answer rating: 100% (QA)
a method to rate a Tetris board and use that rating to find the best possible move Heres a breakdown of the method 1 Rate the Board The first step is to create a method rateBoard that can evaluate the ... View the full answer
Related Book For
Foundations of Financial Management
ISBN: 978-1259024979
10th Canadian edition
Authors: Stanley Block, Geoffrey Hirt, Bartley Danielsen, Doug Short, Michael Perretta
Posted Date:
Students also viewed these programming questions
-
Thomas is a manager who makes decisions quickly. He likes to make decisions on the spot, even if he does not have all of the necessary information. What type of decision - making style is Thomas...
-
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...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Determine the reactions at the beam supports for the given loading when wO = 400 lb/ft. 300 lb/ft A. 5 ft
-
Two friction disks A and B are brought into contact when the angular velocity of disk A is 240 rpm counterclockwise and disk B is at rest. A period of slipping follows and disk B makes 2 revolutions...
-
Here is some information about the tallest buildings in the world as of February 2017. Identify the individuals and variables in this data set. Classify each variable as categorical or quantitative....
-
If you reach for a sweetened carbonated beverage, do you refer to it as soda, pop, coke, or a soft drink? Different regions of the United States use different terms, as shown in this heat map:...
-
Compute the cost of capital for the firm for the following: a. Currently bonds with a similar credit rating and maturity as the firms outstanding debt are selling to yield 8 percent while the...
-
1. What annual payment is required to pay off a four-year, $12,000 loan if the interest rate being charged is 7 percent EAR? What would the monthly payments be for the same loan assuming the same...
-
Find the order of the reaction with respect to the reactants A, B and C . Hint: You can solve this problem using simultaneous equations. What is the value of the rate constant (including units)?...
-
Sylvia accidentally sliced her finger while chopping celery in the restaurant where she worked as an assistant chef. A blood test during the course of her treatment revealed that she not only had an...
-
Solve the following equations by factoring. a. 5x-6x=7x+28 b. 36x4425x Solution(s) Solution(s)
-
Pari bought $2,500 of new furniture on credit. Because her credit score isn't very good, the store is charging her a fairly high interest rate of 16% to finance this purchase. If she agreed to pay...
-
Brooklyn is going to finance new office equipment at a 1% rate over a 2.5 year term. If she can afford monthly payments of $125, how much can she pay for the new office equipment? Round your answer...
-
f(2+ h)-f(2) Find lim if f(x)=-4x-1. h h0 f(2+ h) -f(2) lim h0 (Simplify your answer.) h
-
Find lim h-0 f(2+ h)-f(2) h if f(x) = x+2. f(2+ h)-f(2) lim (Simplify your answer.) h h-0
-
Calcium ions contribute to the hardness of water. a) Based on the Ksp experiment, describe a way to "soften" water by removing calcium ions. 2. b) What would be the advantages and disadvantages of...
-
1. Using the information from Problem 16-4B, prepare a statement of cash flows for Lim Garden Supplies Inc. using the direct method of presenting cash flows from operating activities. 2. How does Lim...
-
In the previous problem, if the 1 million additional shares can be issued only at $23 per share and the company can earn 6.0 percent on the proceeds, should the new issue be undertaken based on...
-
This problem compares the aftertax income on a $35,000 investment for the following two investors resident in Ontario and two possible investments. Table 2-13 will be of assistance. Stanley Truck...
-
Murchie's is considering diversification by way of acquisition to reduce its reliance on its volatile core business. Mad Max, the CEO, has asked for your calculation of a discount rate to be used to...
-
Explain the building blocks of accounting: ethics, principles, and assumptions.
-
On May 1, 2025, Park Flying School Ltd., a company that provides flying lessons, was started with an investment of 45,000 cash in the business. Following are the assets and liabilities of the company...
-
The historical cost basis results in: a. initially recording assets at cost and adjusting when the current value changes. b. keeping activities of an entity separate and distinct from its owner. c....
Study smarter with the SolutionInn App