Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Macroeconomics Expert

The game ofNim. This is a well-known game with a number of variants. We will consider the following variant, which has an interesting winning strategy. Two players alternately take marbles from a pile. In each move, a player chooses how many marbles to take. The player must take at least one but at most half of the mar ­bles. Then the other player takes a turn. The player who takes the last marble loses.

"Write a program in which the computer plays against a human opponent. Generate a random integer between 10 and 100 to denote the initial size of the pile. Generate a random integer between 0 and 1 to decide whether the computer or the human takes the first turn. Generate a random integer between 0 and 1 to decide whether the computer plays smart or stupid. In stupid mode, the computer simply takes a random legal value (between 1 and »/2) from the pile whenever it has a turn. In smart mode the computer takes off enough marbles to make the size of the pile a power of two minus 1 -that is, 3, 7,15, 31, or 63. That is always a legal move, except if the size of the pile is currently one less than a power of 2. In that case, the computer makes a random legal move.

Note that the computer cannot be beaten in smart mode when it has the first move, unless the pile size happens to be 15, 31, or 63. Of course, a human player who has the first turn and knows the winning strategy can win against the computer.

When you implement this program, be sure to use classes Pile, Player, and Came. A player can be either stupid, smart, or human. (Human Player objects prompt for input.)

Macroeconomics, Economics

  • Category:- Macroeconomics
  • Reference No.:- M92026720
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Macroeconomics

Production cost analysis and estimation applied problems

Production Cost Analysis and Estimation Applied Problems - Please complete the following two applied problems: Problem 1: William is the owner of a small pizza shop and is thinking of increasing products and lowering cos ...

Question - a relatively new aspect to the marketplaces of a

Question - A relatively new aspect to the marketplaces of a number of cities worldwide is something called the sharing economy, in which people rent assets such as cars and rooms directly from each other. Also called a p ...

Question how would you manage the costs associated with a

Question: How would you manage the costs associated with a value-creation activity? How do costs of operations relate to the strategy of the organization? The response must be typed, single spaced, must be in times new r ...

Question - find a current example of a linear optimization

Question - Find a current example of a linear optimization model used in your industry. Describe the industry's needs, including any unique factors, how the linear optimization model was used, and the problem or challeng ...

Assignment -part 1 -brief description of the company - name

Assignment - PART 1 - BRIEF DESCRIPTION OF THE COMPANY - Name of your company and ASX code Why did you chose this company What do you know about this company Number of shares purchased (show calculations) Total amount of ...

Question janes juice bar has the following cost schedules

Question: Jane's juice bar has the following cost schedules: quantity variable cost total cost 0 vats of juice 0 30 1 10 40 2 25 55 3 45 75 4 70 100 5 100 130 6 135 165 a. calculate average variable cost, average toal co ...

Question draw the supply and demand diagram for reserves

Question: Draw the supply and demand diagram for reserves with the curves intersecting on the downward sloping part of the demand curve - diagram A. Draw a second graph with the intersection taking place on the horizonta ...

Questions 1 in country faraway cigarettes are forbidden so

Questions: 1. In Country Faraway, cigarettes are forbidden, so people trade cigarettes in a blackmarket. The cigarette demand is QD = 12 - P, and the cigarette supply is Qs = 2P. a. Find the equilibrium price and quantit ...

Question the knowledge economy what leads to a patent race

Question: The knowledge economy What leads to a patent race? Is such a race productive or unproductive? Hint: Think of how patents allow companies monopoly power for a temporary period. The response must be typed, single ...

Question - suppose the demand curve for a product is given

Question - Suppose the demand curve for a product is given by Q = 19 - 1P + 2Ps Where P is the price of the product and Ps is the price of a substitute good. The price of the substitute good is $2.40. Suppose P = 0.60. W ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As