Plays against a human opponent

Assignment Help Macroeconomics
Reference no: EM131271993

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.)

Reference no: EM131271993

Questions Cloud

Find the output snr when beam forming is used : Assuming ρ = 10 dB, find the output SNR when beam forming is used on the channel with equal weights on each transmit antenna and optimal weighting at the receiver. Compare with the SNR under beam forming with optimal weights at both the transmitte..
Display all the records for everyone the state ny : Display all the records (and all its fields) for everyone that is in the state "NY." Submit the source code for the solution and the output screenshots for the following list. You can use any appropriate algorithm in the solution.
Methods of online communication among terrorists : After reading this week chapters, answer all of the following Discussion Questions: 1. List and describe the methods of online communication among terrorists.
Describe the flow of data through your network : Describe the flow of data through your network, and explain how your network design provides multiple layers of security. The Internet cloud, generically, to represent your network's interface to the Internet.
Plays against a human opponent : 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.
Derive the after-tax loss matrix for die firm : A firm has the following probability distribution for annual losses due to vandalism. Derive the after-tax loss matrix for die firm. If the risk manager's decision rule is to minimize after-tax expected cost, which option will she choose? Show why
What is the overhead associated with this µ : What value of µ is needed for the prefix to eliminate ISI between vector code words? What is the overhead associated with this µ?
What do you think would be possible solutions : What do you think are some possibilities for the cause of the problem? If making assumptions, please state what those assumptions are. What do you think would be possible solutions?
What maximum and minimum data rates could be achieved : Find the data rate of an 802.11a system assuming half the available 48 subchannels use BPSK with a rate-1/2 channel code and the others use 64-QAM with a rate-3/4 channel code.

Reviews

Write a Review

Macroeconomics Questions & Answers

  Rise in the price of tv sets in japan also depreciation

Rise in the price of TV sets in Japan also depreciation of the dollar lead to a total increase of 9 percent in the dollar price of imported.

  Many would consider the us postal service a publically good

Many would consider the US Postal Service a publically good. Is this assumption valid.

  Explain complexities that would arise under new scenarios

Assume that Microsoft is considering a merger. The possible merger faces some threats and that the industry desides on self-expansion as an alternative strategy, describe the additional complexities that would arise under this new scenario of expa..

  Explain how does the leontief paradox challenge the overall

Explain how does the Leontief paradox challenge the overall applicability of the factor-endowment model.

  What is the labor-abundant country

What is the labor-intensive good - What is the Marginal Rate of Transformation impact and what is the labor-abundant country?

  How changes in equilibrium occur as result of changes

Identify and discuse the IS-LM framework(determination of income and interest rate) and the wquivalentAD-AS framework (determination of price level andincome) and how changes in equilibrium occur as a result of changes in fiscal and money policy..

  If your worker stated that they would match

If your worker stated that they would match your contributions up to 50 percent, and how much would you contribute.

  Do you think the household is ambiguous

Describe how a budget constraint of a house hold in a two-period model is affected by each of the following changes. In each case, do you think the household is better off , or worse off, or is it ambiguous.

  Mega-super-bigball-lottery

This is typically the kind of research that would be handled by our legal department but they are currently swamped with defending a lawsuit bought against us because of the unfortunate actions of one of our consultants and reduced resources cause..

  What is the difference between a caucus and a primary

In your own words, what is the difference between a caucus and a primary? What are the advantages and disadvantages of each? Lastly, why do so many states still use caucuses despite them resulting in such low voter turnout?

  Elucidate the excess of cost over the marginal price

Elucidate the excess of cost over the marginal price at the profit maximizing price-quantity combination?

  Determine net initial investment

A corporation bought a machine for $100,000 four years ago. It was being depreciated on a straight line basis over five years. The company decides to replace this machine today.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd