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

  Explain components of information systems

Using the three components of information systems and the complementary assets concepts, discuss why some companies achieve better results with information systems than others.

  Web forms controls

Using Web Forms controls,create a Web application to include a TextBox object,a Button object,and a ListBox object. Allow the user to input values into the TextBox.Use those values to populate the ListBox object.

  How much of program-s time slice can be spent waiting

Desired data to rotate around to the read/write head, how much of a program's time slice can be spent waiting for a read operation from a disk to take place?

  Prior insertion system.out.printf formatting output in java

Prior to insertion of System.out.printf(), formatting the output to the console in Java

  Probability and set theory questions

COMP 2804 Assignment 3,  The Fibonacci numbers are defined as follows,  Assume we roll each of D1, D2, and D3 once, independently of each other. Let R 1 , R2, and R3 be the numbers on the top face of D1, D2, and D3, respectively.

  Input function to prompt the user to enter a square

In the script file, use the input function to prompt the user to enter a square 2-dimensional array. Use a loop to check that user's input is a square array and repeatedly ask the user to enter a square array until they enter a square array (you m..

  Use to create style sheets for your web pages

Write a 2-3 page essay that compares the features of two different CSS software packages and describe which you as a web designer might use to create style sheets for your Web pages and why. Explain the benefits of using CSS in developing your web..

  Bob''s encryption company

Suppose Bob's encryption company produces two machines, A and B, both of this are supposed to be implemen- tations of RSA using the same modulus n = pq for some unknown primes p and q

  Explaining cash-drawer management concept

Explain in scholarly detail cash-drawer management concept and its relationship to departmental Budget vs. Actual control process.

  Construct a 3-bit counter using three d flip-flops

Construct a 3-bit counter using three D flip-flops and a selection of gates. The inputs should consist of a signal that resets the counter to 0, called reset, and a signal to increment the counter, called inc.

  Explaining why facebook-s design is different

Why is Facebook's design different? Or has Google merely perfected something that most organizations have just now started to "tackle"?

  Determine the effective miss rate

For the following repeating sequence of 1w address (given in hex) and cache configurations... Assuming least recently used (LRU) replacement for associative caches,

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