1 #!/usr/bin/python
2 from gostyle import PlayerStrategyIdentificator
4 # TODO following method is total XXX
5 # basically whole concept of static class Data is somewhat shallow, and not a good style Python
6 def questionare_average(questionare_list,silent=False):
7 import numpy
8 total={}
9 count={}
10 for questionare in questionare_list:
11 for name in questionare.keys():
12 if name in count:
13 count[name] += 1
14 else:
15 count[name] = 1
16 total[name] = []
17 total[name].append(questionare[name])
19 l=[]
20 for name, counter in count.items():
21 l.append( (counter, name) )
22 l.sort()
23 l.reverse()
24 variance=[]
25 result={}
26 for counter, name in l:
27 if counter > 1:
28 means=[]
29 if not silent:
30 space = 0 if len(name) > 20 else ' '*(20 - len(name))
31 print "%d: %s"%(counter, name + space),
32 a = numpy.array(total[name]).transpose()
33 for b in a:
34 means.append(b.mean())
35 if not silent:
36 print u"%2.3f \u00B1 %2.3f "%(b.mean(), numpy.sqrt(b.var())),
37 variance.append(numpy.sqrt(b.var()))
38 if not silent:
39 print
40 variance.append(numpy.sqrt(b.var()))
41 result[name] = means
42 if not silent:
43 print "Mean standard deviation is: %2.3f"%(numpy.array(variance).mean(),)
44 return result
46 class Data:
47 ### A path to a main pattern file that should contain the most representative patterns along with their occurences
48 ### For its precise format, see `gostyle.py'
49 main_pat_filename = '../pdb-cont/all.pat'
50 ### Folder with player pat files
51 pat_files_folder = '../pdb-cont/pat_files/'
52 ### Pat files should be named ater players
54 ### Explicit list of players
55 #players_all = ['Takemiya Masaki', 'Cho Tae-hyeon', 'Yoda Norimoto', 'Chen Zude', 'Sakata Eio', 'Luo Xihe', 'Gu Li', 'Jie Li', 'Cho Chikun', 'Cho U', 'Suzuki Goro', 'O Meien', 'Miyazawa Goro', 'Wu Songsheng', 'Ma Xiaochun', 'Yasuda Shusaku', 'Kuwahara Shusaku', 'Honinbo Shusaku', 'Go Seigen', 'Shao Zhenzhong', "Yi Ch'ang-ho", 'Ishida Yoshio', 'Kobayashi Koichi', 'Rui Naiwei', 'Yi Se-tol', 'Kato Masao', 'Nie Weiping']
56 players_all = ['Chen Yaoye', 'Chen Zude', 'Cho Chikun', 'Cho Tae-hyeon', 'Cho U', 'Fujisawa Hideyuki', 'Go Seigen', 'Gu Li', 'Hane Naoki', 'Honinbo Dosaku', 'Honinbo Shusaku', 'Honinbo Shuwa', 'Huang Longshi', 'Ishida Yoshio', 'Jie Li', 'Kato Masao', 'Kato Shin', 'Kobayashi Koichi', 'Kuwahara Shusaku', 'Luo Xihe', 'Ma Xiaochun', 'Miyazawa Goro', 'Nie Weiping', 'O Meien', 'Otake Hideo', 'Rui Naiwei', 'Sakata Eio', 'Shao Zhenzhong', 'Suzuki Goro', 'Takao Shinji', 'Takemiya Masaki', 'Wu Songsheng', 'Yamashita Keigo', 'Yasuda Shusaku', "Yi Ch'ang-ho 2005+", 'Yi Se-tol', 'Yoda Norimoto', 'Yuki Satoshi']
57 #players_all = ['d01', 'd02', 'd03', 'd04', 'k01', 'k02', 'k03', 'k04', 'k05', 'k06', 'k07', 'k08', 'k09', 'k10', 'k11', 'k12', 'k13', 'k14', 'k15', 'k16', 'k17', 'k18', 'k19', 'k20', 'k21', 'k22', 'k23', 'k24', 'k25', 'k26', 'k27', 'k28', 'k29', 'k30']
59 ### Thist is used for StrategyOutputVectorGenerator (see gostyle.py)
60 strategy_players = {
61 "territorial":[ 'Cho Chikun', 'Cho U', 'Suzuki Goro'],
62 "agressive":[ 'Kobayashi Koichi', 'Rui Naiwei', 'Yi Se-tol' ],
63 "careful":[ "Yi Ch'ang-ho", 'Ishida Yoshio' ],
64 "moyo":[ 'Takemiya Masaki', 'Cho Tae-hyeon'],
65 "attacking":[ 'Kato Masao', 'Nie Weiping'],
66 "flexible":[ 'Ma Xiaochun' , 'Yasuda Shusaku', 'Kuwahara Shusaku', 'Honinbo Shusaku', 'Go Seigen', 'Shao Zhenzhong' ],
67 "wild":[ 'O Meien', 'Miyazawa Goro', 'Wu Songsheng'],
68 "tesuji focused":[ 'Sakata Eio', 'Luo Xihe', 'Gu Li', 'Jie Li'],
69 "misc":[ 'Yoda Norimoto', 'Chen Zude' ]
72 ### Thist is used for PlanarOutputVectorGenerator (see gostyle.py)
73 player_vector = {
74 "Cho Chikun": [ 1.0, 0.0 ],
75 "Yi Se-tol": [ 0.0, 1.0 ],
76 "Yi Ch'ang-ho": [ 0.0, -1.0 ],
77 "Ma Xiaochun": [ 0.0, 0.0 ],
78 #"Honinbo Shusaku": [ 0.0, 0.0 ],
79 #"Go Seigen": [ 0.0, 0.0 ],
80 "Ishida Yoshio": [ 0.0, -0.5 ],
81 "Rui Naiwei": [ 0.5, 1.0 ],
82 "Sakata Eio": [ 0.5, 0.5 ],
83 "Takemiya Masaki": [ -1.0, 0.0 ]
84 # 'd04': [0.0,1.0 ],
85 # 'd03': [0.0,0.9394 ],
86 # 'd02': [0.0,0.8788 ],
87 # 'd01': [0.0,0.8182 ],
88 # 'k01': [0.0,0.7576 ],
89 # 'k02': [0.0,0.697 ],
90 # 'k03': [0.0,0.6364 ],
91 # 'k04': [0.0,0.5758 ],
92 # 'k05': [0.0,0.5152 ],
93 # 'k06': [0.0,0.4546 ],
94 # 'k07': [0.0,0.394 ],
95 # 'k08': [0.0,0.3334 ],
96 # 'k09': [0.0,0.2728 ],
97 # 'k10': [0.0,0.2122 ],
98 # 'k11': [0.0,0.1516 ],
99 # 'k12': [0.0,0.0910000000000002 ],
100 # 'k13': [0.0,0.0304000000000002 ],
101 # 'k14': [0.0,-0.0301999999999998],
102 # 'k15': [0.0,-0.0907999999999998],
103 # 'k16': [0.0,-0.1514 ],
104 # 'k17': [0.0,-0.212 ],
105 # 'k18': [0.0,-0.2726 ],
106 # 'k19': [0.0,-0.3332 ],
107 # 'k20': [0.0,-0.3938 ],
108 # 'k21': [0.0,-0.4544 ],
109 # 'k22': [0.0,-0.515 ],
110 # 'k23': [0.0,-0.5756 ],
111 # 'k24': [0.0,-0.6362 ],
112 # 'k25': [0.0,-0.6968 ],
113 # 'k26': [0.0,-0.7574 ],
114 # 'k27': [0.0,-0.818 ],
115 # 'k28': [0.0,-0.8786 ],
116 # 'k29': [0.0,-0.9392 ],
117 # 'k30': [0.0,-0.9998 ]
121 ### Following code consist of expert based knowledge kindly supplied by
122 ### Alexander Dinerstein 3-pro, Motoki Noguchi 7-dan and Vit Brunner 4-dan)
124 ### The vector at each name corresponds with
125 ### (Territory, Orthodox, Aggressiveness, Thickness)
126 questionare_vit_brun = {
127 "Chen Yaoye": (7, 5, 7, 6),
128 "Cho Chikun": (9, 7, 7, 9),
129 "Cho U": (4, 6, 7, 4),
130 "Gu Li": (5, 6, 9, 5),
131 "Ishida Yoshio": (6, 3, 5, 5),
132 "Luo Xihe": (8, 4, 7, 7),
133 "Ma Xiaochun": (5, 7, 7, 7),
134 "O Meien": (3, 9, 6, 5),
135 "Otake Hideo": (4, 3, 6, 5),
136 "Rui Naiwei": (5, 6, 8, 5),
137 "Sakata Eio": (6, 4, 8, 6),
138 "Takemiya Masaki": (1, 4, 7, 2),
139 "Yi Ch'ang-ho 2004-": (7, 6, 4, 4),
140 "Yi Ch'ang-ho 2005+": (7, 6, 6, 4),
141 "Yi Se-tol": (6, 5, 9, 5),
142 "Yoda Norimoto": (4, 4, 7, 3)
144 questionare_motoki_noguchi = {
145 "Cho Chikun": (8, 9, 8, 8 ),
146 "Cho U": (9, 7, 6, 8),
147 "Gu Li": (7, 8, 10, 4 ),
148 "Ishida Yoshio": (9, 6, 2, 6),
149 "Luo Xihe": (6, 8, 9, 7 ),
150 "Ma Xiaochun": (9, 6, 7, 8),
151 "O Meien": (1, 10, 10, 2 ),
152 "Otake Hideo": (4, 3, 5, 3),
153 "Rui Naiwei": (6, 6, 10, 2),
154 "Sakata Eio": (10, 5, 6, 10),
155 "Takemiya Masaki": (2,6, 6, 1),
156 "Yi Ch'ang-ho 2004-": (8, 3, 2, 3),
157 "Yi Se-tol": (5, 10, 10, 8 ),
158 "Yoda Norimoto": (8, 2, 2, 5),
159 "Fujisawa Hideyuki": (4, 8, 7, 4 ),
160 "Go Seigen": (8, 10, 9, 6),
161 "Hane Naoki": (8, 2, 4, 6 ),
162 "Honinbo Dosaku": (2, 10, 8, 5 ),
163 "Honinbo Shusaku": (8, 3, 2, 6),
164 "Honinbo Shuwa": (10, 8, 2, 10),
165 "Kato Masao": (2,3, 9, 4),
166 "Kobayashi Koichi": (8, 3, 3, 6),
167 "Miyazawa Goro": (1, 10, 10, 3),
168 "Takao Shinji": (4, 3, 7, 4 ),
169 "Yamashita Keigo": (2, 8, 10, 4 ),
170 "Yuki Satoshi": (2, 8, 10, 4)
172 questionare_alex_dinner = {
173 "Chen Yaoye": (5, 3, 5, 5),
174 "Cho Chikun": (10, 7, 5, 10),
175 "Cho U": (9, 5, 3, 7),
176 "Gu Li": (5, 7, 8, 3),
177 "Ishida Yoshio": (9, 6, 3, 5),
178 "Luo Xihe": (8, 10, 7, 4),
179 "Ma Xiaochun": (10, 6, 3, 9),
180 "O Meien": (4, 10, 9, 4),
181 "Otake Hideo": (5, 3, 3, 3),
182 "Rui Naiwei": (3, 5, 9, 3),
183 "Sakata Eio": (7, 5, 8, 8),
184 "Takemiya Masaki": (1, 9, 8, 1),
185 "Yi Ch'ang-ho 2004-": (6, 6, 2, 1),
186 "Yi Ch'ang-ho 2005+": (5, 4, 5, 3),
187 "Yi Se-tol": (5, 5, 9, 7),
188 "Yoda Norimoto": (7, 7, 4, 2),
189 "Chen Zude": (3, 8, 6, 5),
190 "Cho Tae-hyeon": (1, 4, 4, 2),
191 "Fujisawa Hideyuki": (3, 10, 7, 4),
192 "Go Seigen": (4, 8, 7, 4),
193 "Hane Naoki": (7, 3, 4, 3),
194 "Jie Li (USA)": (5, 3, 5, 4),
195 "Kato Masao": (3, 6, 10, 4),
196 "Kobayashi Koichi": (10, 2, 2, 5),
197 "Miyazawa Goro": (2, 10, 9, 5),
198 "Nie Weiping": (3, 7, 8, 4),
199 "Shao Zhenzhong": (4, 5, 5, 4),
200 "Suzuki Goro": (4, 7, 5, 5),
201 "Takao Shinji": (6, 4, 4, 5),
202 "Wu Songsheng": (2, 10, 7, 4),
203 "Yamashita Keigo": (2, 10, 9, 2),
204 "Yuki Satoshi": (4, 9, 8, 5),
205 "breakfast": (7, 7, 3, 4),
206 "rapyuta/daien": (4, 7, 6, 5),
207 "MilanMilan": (5, 5, 6, 4),
208 "roln111-": (6, 5, 7, 5),
209 "somerville": (4, 5, 5, 6),
210 "artem92-": (7, 4, 3, 2),
211 "TheCaptain": (3, 8, 7, 6)
213 questionare_list = [ questionare_vit_brun, questionare_motoki_noguchi, questionare_alex_dinner ]
214 questionare_total = questionare_average(questionare_list,silent=True)
216 def questionare_variance():
217 questionare_average(Data.questionare_list)
219 if __name__ == '__main__':
220 import sys
222 for arg in sys.argv:
223 if arg == '-p' or arg == '--all-players':
224 for p in Data.players_all:
225 print p
226 if arg == '-h' or arg == '--help':
227 print sys.argv[0], " [OPTIONS]"
228 print """
230 OPTIONS
231 -p, --all-players
232 prints a list of known players to the STDOUT.
233 -h, --help
234 help!