Program 2: The Game of NimThis is a well-known game with a number of variations. We will consider one for this program. Two players alternately take marbles from a pile. In each move, a player...

I want someone to do the assignment for me due to the lack of time I have to complete it.


Program 2: The Game of Nim This is a well-known game with a number of variations. We will consider one for this program. Two players alternately take marbles from a pile. In each move, a player chooses how many marbles to take. The player must take at least one but at most half of the marbles. Then the other player takes a turn. The player who takes the last marble loses. Write a program that has the computer play against a human. · Ask the user if they want an easy or a hard challenge. · The initial size of the pile is a random integer between 10 and 100. · Who goes first is decided by a random boolean. · EASY GAME: When the computer has a turn, it takes a random number of marbles (between 1 and half the pile). · HARD GAME: When possible, the computer takes off enough marbles to make the pile’s size equal to a power of 2 minus one (2^n – 1). If that’s not possible, the computer chooses randomly like before (gee, guess that means the random choosing should be its own function so you don’t have to write it twice!). Coding requirements: Use subroutines.
Oct 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here