Last active
March 17, 2016 02:18
-
-
Save LandonPowell/3a4432c7284f49a600d6 to your computer and use it in GitHub Desktop.
Python Nim Implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print( | |
"Welcome to Nim!:\n"+ | |
"A simple game, where you're allowed to take "+ | |
"one, two, or three marbles from a pile of 12.\n"+ | |
"You compete against the computer to take the "+ | |
"last marble.") | |
marbles = 12 | |
def computerTake(amount): | |
global marbles # Python goes full retard without this. | |
print("I'll take "+ str(amount) +" of the marbles.") | |
marbles -= amount | |
print("Now we have "+ str(marbles) +" marbles left.") | |
while marbles: | |
print("\nMarbles: " + "o"*marbles) | |
choice = int(input("1, 2, or 3?> ")) | |
marbles -= choice | |
if choice in range(1, 4): computerTake(4 - choice) | |
else: print("Stop cheating, sux0r!") | |
print("It looks like I win again!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment