Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. This function does not return anything. find_and_replace(new_brick, brick_to_be_replaced, tower, discard): Find the given brick to be replaced (represented by an integer) in the given

image text in transcribed
. This function does not return anything. find_and_replace(new_brick, brick_to_be_replaced, tower, discard): Find the given brick to be replaced (represented by an integer) in the given tower and replace it with the given new brick. Check and make sure that the given brick to be replaced is truly a brick in the given tower. The given brick to be replaced then gets put on top of the given discard pile. . Return True if the given brick is replaced, otherwise return False. computer_play(tower, main_pile, discard): . This function is where you can write the computer's strategy. It is also the function where we are giving you very little guidance in terms of actual code. . You are supposed to be somewhat creative here, but I do want your code to be deterministic. That is, given a particular tower and a particular brick (either from the discarded brick pile or as the top brick of the main pile), you either always take the brick or always reject it. Here are some potential decisions the computer has to make: Given the computer's current tower, do you want to take the top brick from the discarded brick pile or do you want to take the top brick from the main pile and see if that brick is useful to you. o How do you evaluate the usefulness of a brick and which position it should go into. There might be some simple rules you can give the computer. For instance, it is disastrous (probably so) to put something like a 5 at the very bottom of the tower. You want big numbers over there. You are allowed to do pretty much anything in this function except make a random decision or make a decision that is obviously incorrect. For instance, making your bottom brick a 5 is not very smart and a recipe for disaster. Also, the computer CANNOT CHEAT. What does that mean? The computer cannot peek at the top brick of the main pile and then make a decision to go to the discard pile. Its decisions should be something that a human could be able to make as well This function returns the new tower for the computer. Hint: One approach is to try to think of how you, as a human user, would consider selecting a new brick (from the main pile or discard pile) and using it to replace a brick in your own tower. main (): . The function that puts it all together

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions