![]() In the example above, it appears that 7 sticks were used in the game. Round 3: 1 at start computer takes 1, so 0 remainīegin by prompting the user for the initial number of sticks. Round 2: 3 at start human takes 2, so 1 remain ![]() ![]() Round 1: 5 at start computer takes 2, so 3 remain Round 0: 7 at start human takes 2, so 5 remain While there is a winning strategy for this game, you are only required to create a computer player that makes random, but valid, moves. To simplify your work the person will always take the first turn. You will design a game in which one human player is competing against a computer. The goal of the game is to be the player who removes the last stick. On each turn a player must remove either 1 or 2 sticks from the pile. There are many variations of Nim but we will stick with a simple version. Nim is a game of strategy in which two players take turns removing sticks from a common pile. Then follow the same accept/import process described in the setup instructions. Assignment 2: Game of Nim ¶ Assignment Setup ¶
0 Comments
Leave a Reply. |