Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

when the code is complete it should run with the code i provided do not alter any completed functions just add in the function that will make the code work 1

Write a program that plays the subtraction game (Nim). We have written a simplied version before….as a reminder, The game is such that there are initially 21 stones. Each player takes turns removing 1-3 stones on their turn (their choice). Play alternates back and forth. The person who takes the last stone is the loser… Rather than having another player have a computer AI remove 1-3 stones randomly (to a degree, when 4 stones or less hard-coded choices). Create at least two functions, aiMove, and userMove…these functions should return the amount of stones to take from the pot.

Need assignment help for this question?

If you need assistance with writing your essay, we are ready to help you!

OUR PROCESS

Order

Payment

Writing

Delivery

Why Choose Us: Cost-efficiency, Plagiarism free, Money Back Guarantee, On-time Delivery, Total Сonfidentiality, 24/7 Support, 100% originality

code:

import random

def main():

stones = 21;

#TODO:

# – Randomly determine starting player

# – Alternate between AI and User, calling their methods

# – When a player takes the last stone, end the game and state that they lost.

def userTurn(sPile):

“””

A function that asks the user how many stones to take, and returns that amount. It also checks to make sure that

the user enters a valid choice (1-3, or less if the pile of stones doesn’t have 3).

:param sPile the number of stones in the pile

:return the valid number of stones to take —0 is place holder

“””

#TODO: complete the method to ask the user for a number of stones to take (keep asking until valid).

return(0)

def aiTurn(sPile):

“””

A function that randomly generates a number of stones to take…1-3, or use if-statements when 4 or less stones remaining

:param sPile the number of stones in the pile

:return the valid number of stones to take —0 is place holder

“””

#TODO: complete the method to randomly generate the number of stones to take.

return(0)

main()

"Order a similar paper and get 15% discount on your first order with us
Use the following coupon
"FIRST15"

Order Now