Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Business Management 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.)

Business Management, Management Studies

  • Category:- Business Management
  • Reference No.:- M92022054
  • Price:- $20

Priced at Now at $20, Verified Solution

Have any Question?


Related Questions in Business Management

How negotiation compromise and settlement could be

How negotiation (compromise and settlement) could be implemented in fee dispute? And the Implications?

Describe your approach to tracking a project what kind of

Describe your approach to tracking a project, what kind of issues would focus on if you were a project manager.

The hecksher-ohlin model predicts that each country would

The Hecksher-Ohlin model predicts that each country would export the good that intensively uses the country's relatively abundant factor. Does this H-O prediction remain consistent with the empirical findings, in general ...

What steps has whole foods taken in approprately planning

What steps has Whole Foods taken in approprately planning strategy? Assuming WFoods must develop a new business model, how should they go about this?

The balanced scoreboard approach has gained popularity in

The balanced scoreboard approach has gained popularity in recent years. What is this approach and how does it integrate strategic and operational control?

Prove that if an eulerian path exists in a connected

Prove that if an Eulerian path exists in a connected directed acyclic graph that contains at least one self loop from a vertex to itself, then an Eulerian path also exists after the self loops are removed.

Government policies can give indias biotech industry an

Government policies can give India's biotech industry an opportunity to enter a market segment. What specific policies favor the biotech industry? How do these links back to the Porter Diamond?

Describe the types of courage that an effective follower

Describe the types of courage that an effective follower should have.

Why are we in the golden age of technology entrepreneurship

Why are we in the 'golden age' of technology entrepreneurship? What factors are helping entrepreneurs more rapidly achieve their vision, and with a lower cost?

Examples of national quality control models whats are the

Examples of national quality control models? whats are the key concepts?

  • 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