Question: Why doesn't my code match the output in the samples? ( You should include your name and section number as part of the comments
Why doesn't my code match the output in the samples?
You should include your name and section number as part of the comments for your
project assignment!!!
Testing Cases
First, you should test running your program a few times with each the following "hard
coded" initial pile sizes: and Under each initial pile size, try to generate
the different cases: Computer plays first; The user plays first; The computer
player wins the game; The user wins the game.
Second, you should test running your program a few times with randomly generated
initial pile size, try to generate the different cases as described above.
The following are some sample outputs when you run your program:
Note that the blue part represents the user input, and represents the enterreturn key
from the user input.
Sample output :
Welcome to the game of Nim for two players
Please input your name: Yi Pike
The game of Nim
Players alternate taking at least one but at
most half of the marbles in the pile.
The player who takes the last marble loses.
It is written by Yi Pike
I hope you beat the computer:
No matter what, have a great day!
Yi Pike will play first.
Then followed by the Computer.
There are marbles in the pile.
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
Phi
PhiIt is Yi Pike's turn:
Your turn to play you may take to marbles.You
take: I will move marbles
Invalid! Please try again...
Your turn to play you may take to marbles.You
take: ten marbles
Invalid! Please try again...
Your turn to play you may take to marbles.You
take: marbles ok
You will take marbles.
There are marbles in the pile. You should include your name and section number as part of the comements for your
projoct assignment!!!
Testing Cases
First, you should tast ruming your program a few times with each the following "hard
coded" initial pile sizses: and Uvder asch initial pile sizes, try to genesate
the diffareat cases: Comprater plays first, The user plays firnt; The computar
player wins the grome; The nser wins the game.
Second you sbould tast ranning your program a fow times with randomly genarated
initial piles size, try to generate the different cases as described above.
The following are some sample outputs when you ran your program:
Note that the blue part represents the mer input, and repreveats the anterretarn key
from the mer input
Sample output :
Welcome to the game of Nim for two players
Please input your name: Yi Pike
the game of Ni
Players alternate taking at least one but at
most half of the marbles in the pile.
The player who takes the last marble loses.
It is written by pike
I hope you beat the conputer:
No matter what, have a great day
Yi Pike will play first.
Then followed by the Computer.
There are marbles in the pile.
It is Pike's turn:
Your turn to play you may take to marbles.You
take: I will nove marblest
Invalid Please try again..
Your turn to play you may take to marbles. You
take: ten marbles
Your tul Please try again..
Your turn to play you may take to marbles.You
take: marbles ok
There are marbles in the pile.
It is Conputer's turn
The computer takes marbles.
There are marbles in the pile.
It is Pike's turn:
Your turn to play you may take to marbles.It is ri Pike"s turn:
Your turn to play you may take to marbles.
You take: seven I guesst
Invalidl Please try again..
Your turn to play you may take to marbles.
Ooops, you picked too many or not enough.
please try again...
Your turn to play.. you may take to marbles.
You take: is my choicet
You wll take marbles.
There are marbles in the pile.
It is Computer's turn
The computer takes marbles.
There are marbles in the pile.
It is Yi Pike's turn:
Your turn to play.. you may take to marbles.
You take: marbles ok
You will take marbles.
There are marbles in the pile.
@
It is Conputer's turn:
The computer takes marbles.
There are marbles in the pile.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
