Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Honest Bot Dishonest
- Win 3 2
- Draw 2 1
- Loss 1 0
- def honestpaper(I,dont,care,about_these):
- return "P"
- def honestrock(I,dont,care,about_these):
- return "R"
- def honestscissors(I,dont,care,about_these):
- return "S"
- import random
- def randombot(I,dont,care,about_these):
- return random.choice(["R","P","S"])
- from honestrock import honestrock
- from honestpaper import honestpaper
- from honestscissors import honestscissors
- from randombot import randombot
- bot_map = {
- 0:honestrock, 1:honestpaper, 2:honestscissors, 3:randombot
- }
- player_num=len(bot_map)
- def real(history1,history2,number,honest1,honest2):
- return bot_map[number](history1,history2,honest1,honest2)
- def honest(history1,history2,number):
- return bot_map[number](history1,history2,None,None)
- def play_match(num1,num2):
- history1=[]
- history2=[]
- score1=0
- score2=0
- for x in range(250):
- h1=honest(history2,history1,num1)
- h2=honest(history1,history2,num2)
- r1=real(history2,history1,num1,h2,h1)
- r2=real(history1,history2,num2,h1,h2)
- if h1==r1: score1+=1
- if h2==r2: score2+=1
- if r1==r2: score1+=1; score2+=1
- elif r1=="R":
- if r2=="P": score2+=2
- else: score1+=1
- elif r1=="P":
- if r2=="S": score2+=2
- else: score1+=2
- else:
- if r2=="R": score2+=2
- else: score1+=2
- history1.append([h1,r1])
- history2.append([h2,r2])
- return score1,score2
- scores = []
- for x in range(player_num):
- scores.append(0)
- for x in range(100):
- for x in range(player_num):
- for y in range(player_num):
- scorex,scorey=play_match(x,y)
- scores[x]+=scorex
- scores[y]+=scorey
- for score in scores:
- print score
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement