Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java programming language Game of Nim Nim is a game of strategy in which two players take turns removing sticks from a common pile. There

Java programming language

image text in transcribed

Game of Nim Nim is a game of strategy in which two players take turns removing sticks from a common pile. There are many variations of Nim but for the purposes of this assignment, we will stick with a simple and common implementation. On each turn, a player must remove either 1 or 2 sticks from the pile. The goal of the game is to be the player who removes the last stick. In this assignment, you will design a game in which one human player is competing against a computer. The human player should also be able to decide if he or she wants to play the first or second move. It's important to note that while there is a winning strategy for this game, you are required only to implement a computer player which employs random moves. Example output of one game: Computer starts Round o, 7 sticks at start, computer took 2, so 5 sticks remain Round 1,5 sticks at start, human took 1, so 4 sticks remain Round 2,4 sticks at start, computer took 2, so 2 sticks remain Round 3, 2 sticks at start, human took 1, so 1 sticks remain Round 4, 1 sticks at start, computer took 1, so o sticks remain Computer wins Notes Clearly, the human could have played better in the above game. The computer randomly removes 1 or 2 sticks, but cannot remove more sticks than are left. The human is prompted at each turn for how many sticks he or she wants to remove. Be careful! A human might enter 5 if 5 sticks are left, and if you are not careful, the human could win by playing in that way

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Make an argument against disclosure.

Answered: 1 week ago

Question

LO4 List options for development needs analyses.

Answered: 1 week ago