Embed
Email

Triple-Nim

Document Sample

Shared by: Kerala g
Categories
Tags
Stats
views:
1
posted:
12/5/2011
language:
English
pages:
1
Triple Nim



The game of Nim is played as follows: The game starts with a random number of stones in a

pile from 15 to 30. Two players (one player is the computer) alternate turns and on each turn,

the player has a choice to remove 1, 2, or 3 stones from the pile. The player who removes the

last stone is the loser.



You will write a program that simulates a version of this game with a computer opponent and

three piles instead of just one. It will work as follows – the computer will generate the number

of stones in each pile and then the user will have the first turn. During each turn, the user is

presented with the amount of stones in a pile and is asked how many stones they would like to

remove. This is done for each of the three piles on each turn.



Then the computer player takes a turn and it randomly decides how many (1-3) stones it will

remove from each pile, and it should display how many it removes from each pile. Then it

becomes the user’s turn and continues until one player has won two piles, and is then declared

the winner.



Make sure that you:



 Enforce the rules regarding how many stones the user can remove from a pile (at least

1, no more than 3) – ask the user again if they enter an invalid number.

 Make sure that neither the computer nor the user can remove more stones than there

are in a pile from that pile.

 Be sure that your program does not continue to execute turn based code once the

game is over.



Other docs by Kerala g
union-budget-2012-13-highlights
Views: 89  |  Downloads: 0
notification M.Tech_05-03-09
Views: 58  |  Downloads: 0
India_Customs Regulation 1
Views: 55  |  Downloads: 0
CE Notification 39-2011-12.9.2011
Views: 53  |  Downloads: 0
STATISTICS
Views: 71  |  Downloads: 0
A Hero (R.K. Narayan)
Views: 88  |  Downloads: 6
RRBPatna-Info-HN
Views: 100  |  Downloads: 0
RRB-Notice-Para
Views: 102  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!