Proper outputs your game can play human vs. human, computer vs. computer or huma
ID: 3584175 • Letter: P
Question
Proper outputs
your game can play human vs. human, computer vs. computer or human vs. computer Write a game called Cursed Gold. The object of the game is to make your opponent select the last gold coin from the pile. There are initially 16 gold coins in the pile and you and your opponent take turns selecting 1,2 or 3 pieces of gold. The person who has to take the last piecc from the pile loses. The idea here is to create three functions that represent different strategies. Two of your functions (named playerSimple () and playerSmart ()) are completely automated - think artificial intelligence. They take a single argument - the number of coins currently in the pile. Your functions use this information to decide how to strategize. One of them can be very simple and do the same thing every time but the other function should be a bit more ... intelligent. Random selections are also valid but will only work to a point. These functions print (yes, printing in a function is allowed here) how many coins were removed and they return how many coins arc left - this is important as this number is needed by the next "player". The third function (playerHuman ()) is a human player. This means that it still takes a single argument - the number of coins remaining but it then prompts the user for input (1,2 and 3 are the only valid inputs) and returns the number of gold pieces remaining. All three of the functions can work in different ways but ultimately, all three will have to deal with the pile of coins in a special way when it is down to three or less - keep this in mind. You'll need a main function that initializes the pile to 16 gold pieces. It will also be responsible for looping over the player turns, for printing out the number of pieces remaining after each turn and for determining who won. It also determines whether or not the second player is human and calls the appropriate functions. A few hints from my solution (take them or leave them): I have a function called checkWinner() that determines if a winner exists (only I coin left!!) and stops the loop. In the output below, my player 1 is my smarter computer player while player 2 is my simpler computer player - only slightly but there is a difference. Output from the two computer players playing (no user input):Explanation / Answer
shorten the question
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.