Write a program and create a flow chart

Assignment Help Basic Computer Science
Reference no: EM13306240

The game of Nim. This is a well-known game with a number of variants. We will consider the following variants, 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 marbles. Then the other player takes a turn. The player who takes the last marble loses.

Write a program and create a Flow Chart in which 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 model, the computer simply takes a random legal value (between 1 and n/2) from the pile whenever it has a turn. In smart model the computer takes off enough marbles to make the size of the pile a power of 2 minus 1 - that is, 3, 7, 15, 31, or 63. This 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.

Create a flow chart.

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.

Reference no: EM13306240

Questions Cloud

Determine the change in the period of the heated pendulum : A simple pendulum consists of a ball connected to one end of a thin brass wire. Determine the change in the period of the heated pendulum
Write a program that prompts a salesman : Write a program that prompts a salesman to enter his/her status and total sales. Compute/display the following: their status; total sales; commission rate applied; the commission ($) earned (the appropriate rate times the sales).
How antibodies recognize and neutralize viruses : Explain the how Natural Killer Cells and Cytotoxic T-cells recognize that a cell is infected with a virus and kills the infected cell and how antibodies recognize and neutralize viruses or target viruses for destruction.
How much work is done by the gas during the compression : A monatomic ideal gas that is initially at a pressure of 1.41 * 10^5 Pa, How much work is done by the gas during the compression
Write a program and create a flow chart : The game of Nim. This is a well-known game with a number of variants. We will consider the following variants, which has an interesting winning strategy. Two players alternately take marbles from a pile.
How are adc used in medical devices : How are ADC's used in medical devices? Please give examples
Create a list containing the union of the elements : Create a list containing the union of the elements of the two lists? Insert an element after the nth element of the list.?
Battleship redux : Game Battleship is back and better than ever. Instead of hacking everything together in C, you will instead leverage C++ and all of your newly gained object oriented programming knowledge to construct a much cleaner end product.
Create a jframe that uses borderlayout : Create a JFrame that uses BorderLayout. Place a JButton in the center region. Each time the user clicks the JButton, change the background color in one of the other regions. Save the file as JColorFrame.java.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Internet access providers

Should Internet access providers or telephone companies be allowed to monitor how you use your Internet or telephone connection? Why or why not?

  Write a fragment of code that accepts integers

write a condition to test if the point is outside the rectangle. Assume that x increases to the right and that y increases to the top. 2.Write a fragment of code that accepts integers from the user until a negative number is entered. The prompt sh..

  Develop timeline on computer using microsoft word

Use Microsoft Word, Excel or PowerPoint to develop timeline on computer. Create your own timeline and take a picture, saving file on computer as .jpg or .gif.

  Create a local area network

Create a local area network (LAN) design diagram of the current network that describes the hardware and software resources that Matt described.

  Write code to assign to the variable

Write code to assign to the variable format a formatting string that will display three values referenced by the variables quantity

  What arguments make for single language for all programming

What arguments can you make FOR the idea of a single language for all programming domains? "For" the idea, not the against!

  Verify local police department-s findings on firm-s case

Tension over case is running high in city. What do you require to ask police investigator for, and what procedures must you follow?

  Identification of the concept of a target audience

You are working on a new Web site for Cruzes, Inc. The Web site is aimed at providing travel information to consumers interested in cruises. When meeting with Jason, the marketing manager of Cruzes, Inc

  Give upper bound on number of training

Give an upper bound on the number of training examples sufficient to assure with 90% confidence that the learned perceptron will have true error of at most 5%. Does this bound seem realistic?

  Calculation for programming and machine independency

Assume f is a function that returns the result of reversing string of symbols given as its input, and g is a function that returns concatenation of the 2-strings given as its input. If x is the string abcd,

  Write a proof that uses this approach

An alternative proof of the irrationality of square root of 2 counts the number of 2's on the two sides of the equation 2n^2 = m^2 and uses the unique factorization of integers theorem to deduce a contradiction. Write a proof that uses this approa..

  Write functions and steps for various window applications

Write down the functions and steps involved in various window applications. What is mail merge? Enumerate the steps involved in mail merge.

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