Write a detailed algorithm and a program that plays the ancient Chinese game of NIM. Actually, this is a simplified version of the original game. In this game, the person who runs your program will be one of the two human players, the program should act as the other player, as well as provide the narrative for the game and keep score, invite a friend to be the third player. Your program must keep score impartially while participating in the game.
The program must perform the following:
• Introduce and describe the game, the computer shall introduce itself as the AI player, and prompt the human players for his or her names along with MIT Ids.
• Program is to be interactive to receive and display the response.
• To display a greeting to the human player that incorporates the name provided in response to the prompt: Welcome <user’s name> to the game of Taking Stones.
• The user’s name must be output in proper name case (i.e., mixed case starting with upper case for the first letter) regardless of the case the user types in.
• The users shall input the number of stones to be picked either by using a standard random number generator function or may input according to their own strategy but the number should be less than or equal to three (3) and more than zero.
• The program must reject and display a valid message if the number of stones to be removed are either less than one (1) or more than three (3) and remind them of the game constraints. In case of invalid entries program to prompt that player to re-enter an appropriate number.
• The program should have the computer use the optimal playing strategy. The optimal strategy is as follows: Divide the remaining number of stones by three. If the remainder is zero, then two stones are removed, or else one stone is removed. For example, if the remaining number of stones is nine or fifteen, then two stones are removed; if the remaining number of stones is eight or ten, then one stone is removed.
• Both the human players shall have their own strategies to play.
• When one of the players has won a game, the program must output a congratulatory message naming the winner along with ID.
• The program should allow the users to play additional games of NIM as long as he/she enters a “y” or “yes” (lowercase or uppercase) in response to a “Do you want to play again?” prompt.
10 pekerja bebas membida secara purata $27 untuk pekerjaan ini
Hi! I am expert in Python, Matlab, ML, C++, C, C# and have 12 years experience. I work according to your requirement to provide the best quality and customer satisfaction. Thank you!