• API
• FAQ
• Tools
• Archive
daily pastebin goal
64%
SHARE
TWEET

# Untitled

a guest Oct 12th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Honest Bot       Dishonest
2. Win     3                  2
3. Draw    2                  1
4. Loss    1                  0
5.
7.     return "P"
8.
10.     return "R"
11.
13.     return "S"
14.
15. import random
17.     return random.choice(["R","P","S"])
18.
19. from honestrock import honestrock
20. from honestpaper import honestpaper
21. from honestscissors import honestscissors
22. from randombot import randombot
23.
24. bot_map = {
25.   0:honestrock, 1:honestpaper, 2:honestscissors, 3:randombot
26. }
27.
28. player_num=len(bot_map)
29.
30. def real(history1,history2,number,honest1,honest2):
31.     return bot_map[number](history1,history2,honest1,honest2)
32.
33. def honest(history1,history2,number):
34.     return bot_map[number](history1,history2,None,None)
35.
36. def play_match(num1,num2):
37.     history1=[]
38.     history2=[]
39.     score1=0
40.     score2=0
41.     for x in range(250):
42.         h1=honest(history2,history1,num1)
43.         h2=honest(history1,history2,num2)
44.         r1=real(history2,history1,num1,h2,h1)
45.         r2=real(history1,history2,num2,h1,h2)
46.
47.         if h1==r1: score1+=1
48.         if h2==r2: score2+=1
49.
50.         if r1==r2: score1+=1; score2+=1
51.         elif r1=="R":
52.             if r2=="P": score2+=2
53.             else: score1+=1
54.         elif r1=="P":
55.             if r2=="S": score2+=2
56.             else: score1+=2
57.         else:
58.             if r2=="R": score2+=2
59.             else: score1+=2
60.
61.         history1.append([h1,r1])
62.         history2.append([h2,r2])
63.     return score1,score2
64.
65. scores = []
66. for x in range(player_num):
67.     scores.append(0)
68.
69. for x in range(100):
70.
71.     for x in range(player_num):
72.         for y in range(player_num):
73.             scorex,scorey=play_match(x,y)
74.             scores[x]+=scorex
75.             scores[y]+=scorey
76.
77. for score in scores:
78.     print score
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top