Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- numberSim = int(input("Pick a number of simulations to run, between 10 and 500: "))
- while numberSim <= 10 or numberSim >= 500:
- numberSim = int(input("Please enter a number between 10 and 500: "))
- if numberSim >= 10 or numberSim <= 500:
- print("Excellent, now, pick a strategy:")
- print("1: Random")
- print("2: Always be silent")
- print("3: Always cooperate")
- partnerAstrategy = int(input("Enter your choice: "))
- while partnerAstrategy > 3 or partnerAstrategy < 1:
- partnerAstrategy = int(input("Enter a number from 1 to 3: "))
- if partnerAstrategy == 1:
- partnerAstrategy = randint(1, 2)
- if partnerAstrategy == 2:
- partnerAstrategy = 2
- if partnerAstrategy == 3:
- partnerAstrategy = 1
- if partnerAstrategy == 1 or partnerAstrategy == 2:
- print("Excellent, now, pick a strategy for your partner:")
- print("1: Random")
- print("2: Always be silent")
- print("3: Always cooperate")
- partnerBstrategy = int(input("Enter your choice: "))
- while partnerBstrategy > 3 or partnerBstrategy < 1:
- partnerBstrategy = int(input("Enter a number from 1 to 3: "))
- if partnerBstrategy == 1:
- partnerBstrategy = randint(1, 2)
- if partnerBstrategy == 2:
- partnerBstrategy = 2
- if partnerBstrategy == 3:
- partnerBstrategy = 1
- if partnerBstrategy <= 3 or partnerBstrategy >= 1:
- partnerAchoice = partnerAstrategy
- partnerBchoice = partnerBstrategy
- partnerAtime = 0
- partnerBtime = 0
- for i in range(numberSim):
- if partnerBchoice == 1 and partnerAchoice == 1:
- partnerAtime += 4
- partnerBtime += 4
- if partnerBchoice == 2 and partnerAchoice == 2:
- partnerAtime += 2
- partnerBtime += 2
- if partnerBchoice == 1 and partnerAchoice == 2:
- partnerAtime += 0
- partnerBtime += 6
- if partnerAchoice == 1 and partnerBchoice == 2:
- partnerAtime += 6
- partnerBtime += 0
- valueA = float(partnerAtime / numberSim)
- valueB = float(partnerBtime / numberSim)
- print("You got an average of", valueA, "years")
- print("The computer got an average of", valueB, "years")
Advertisement
Add Comment
Please, Sign In to add comment