Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please do it C++ at a very beginner level. Program: Game of NIM NIM is an ancient and fairly simple game. NIM is a mathematical
Please do it C++ at a very beginner level.
Program: Game of NIM NIM is an ancient and fairly simple game. NIM is a mathematical game of strategy in which two players take turns removing objects from a heap. On each turn, a player must remove 1,2 , or 3 of the objects. The player forced to remove the last object loses. The purpose of this assignment is to reinforce concepts presented earlier and introduces More sophisticated if-else statements. Loops: while and do while Random numbers. Be sure to adequately document your program. The heap starts with 23 objects. Write the game for a player to compete against the computer. That is one player is human and the other is the computer. The human will go first. Then the computer and human alternate turns. When it is the human's turn, Print out the player's name and ask for the move. The move must be between 1 and 3 and cannot be more than what is in the heap. When it is the computer's turn, generate a pseudo random number between 1 and 3 . Make sure it is less than the number of objects in the heap. When the number of objects reaches zero, announce the winner. Random numbers: 1. Necessary includes 2. Seed the random number generator once at the beginning of the program: / * initialize random seed: */ srand (time (NULL)); 3. Generate a random number between 1 and 3 / generate secret number between 1 and 3:/ iMove =rand() \& 3+1; main.cpp Load default template... 123456789#includeiostreamusingnamespacestd;intmain(){/Typeyourcodehere.*/return0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started