Computer plays against a human opponent

Assignment Help Business Management
Reference no: EM131267306

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: EM131267306

Questions Cloud

Calculate the most economical conductor size : The cost of energy is 5P per kWh and interest and depreciation charges amount to 10%. Calculate the most economical conductor size. Assume resistivity of conductor material to be 1·73 μ Ω cm.
Is the treatment cost efficiency : Did the patient receive treatment that benefits his condition? Do I need to use the treatments and the medication they prescribe and their doctors? Is the treatment cost efficiency?
Create a video showing the product that you would like : Think about products that you would love to see revamped to meet your needs or a new product that has not yet been created. Create a video showing the product that you would like to see revamped. Describe the changes you would like to see
Find a product being sold with a mail in rebate offer : Is it unethical to advertise products at their post-rebate price in order to increase sales? Why?- find a product being sold with a mail-in rebate offer.
Computer 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. Generate a random integer between 0 and 1 to decide whether the computer or the human takes ..
Prepare a response to each of the issues : Evaluate the action in this case and apply what you've learned in this chapter and explaining your reasoning carefully - Do you agree? Discuss your answer with reference to the criteria presented in this chapter: consequences, obligations, and moral..
What surprised you about the results of the survey : What surprised you about the results of the survey found in this article? Which parts of this survey would be applicable to the healthcare environment
Stage of the management plan : Suggest the prototyping technique you would use for this system and support your rationale. Create a management plan containing eight to ten (8-10) stages for proper design of such a system. Explain each stage of the management plan and justify your ..
Effectively promote product features and customer service : Evaluate or create printed materials for you chosen company. - Effectively promote product features and customer service? Note a differential or competitive advantage?

Reviews

Write a Review

Business Management Questions & Answers

  Desirous of launching global strategic offensives

Companies desirous of launching global strategic offensives can choose among such strategy options as (1) cross-market subsidization, (2) attacking a rival's profit sanctuaries and (3) dumping goods at cut-rate prices. Explain what is meant by eac..

  Question related to public relations

A good public relations person analyzes reporters and publications he wishes to work with.

  Corporate social responsibility

•You are the author of a popular CSR article. For this week's discussion post, discuss the main reasons why Apple is or is not a socially responsible organization. List at least two examples of Apple's actions that support your position. Be sur..

  Define the term feedback

Class, define the term feedback. Why is feedback essential for problem solving in any system? Please provide an example of feedback in a TQM context.

  Employee training and development

Needs assessment involves organization, person, and task analysis. Which one of these analyses do you believe is most important? Which is least important? Why?

  Scholarly writingwriting well is a hallmark of good

scholarly writingwriting well is a hallmark of good scholarship scholars try to make sense of the world through

  Identify advantages and disadvantages of each contract type

Identify the advantages and disadvantages of each contract type. Demonstrate the ways in which each type of contract addresses project risks. From the list of contract types, make a recommendation to a client for one specific contract type.

  Prepare a speech that involves communicating changes the

prepare a speech that involves communicating changes. the topic involves communication changes personal changes or

  Barriers to entry crucial to the success of a monopoly firm

Why are barriers to entry crucial to the success of a monopoly firm? Explain why all monopoly profits will show up as returns to the factor or factors that provide the barrier to entry?

  Unbiased expectations theories

According to the unbiased expectations theories, what does the market expect the 1-year Treasury rate to be eight years from today, E(9r1)? (Do not round intermediate calculations and round your answer to 2 decimal places.)

  Comparison of formal research and business proposals

What are some differences? What are the capabilities of one in contrast with the capabilities of the other?

  How should you act in the given situations

In light of what you have learned in this chapter, how should you act in the following situations? Are the actions legal or illegal?

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