data_about_players: Info about median years of selected players
[gostyle.git] / data_about_players.py
bloba4aba4c3a2b94be5a27b2d605dc5a36dd4d88cb3
1 #!/usr/bin/python
2 from gostyle import Rescale
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 homedir='../pdb/'
50 #homedir='../pdb-cont/'
51 #homedir='../pdb-notenuki/'
52 #homedir='../pdb-gtl/'
54 main_pat_filename = homedir + 'all.pat'
55 ### Folder with player pat files
56 pat_files_folder = homedir + 'pat_files/'
57 ### Pat files should be named ater players
59 ### Explicit list of players
60 #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']
61 #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']
62 # Set-in-paper:
63 players_all = [ 'Yoda Norimoto', 'Yi Se-tol', "Yi Ch'ang-ho", 'Takemiya Masaki', 'Sakata Eio', 'Rui Naiwei', 'Otake Hideo', 'O Meien', 'Ma Xiaochun', 'Luo Xihe', 'Ishida Yoshio', 'Gu Li', 'Cho U', 'Cho Chikun', 'Yuki Satoshi', 'Yamashita Keigo', 'Takao Shinji', 'Miyazawa Goro', 'Kobayashi Koichi', 'Kato Masao', 'Hane Naoki', 'Go Seigen', 'Fujisawa Hideyuki', 'Chen Yaoye' ]
65 strength_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']
67 ### Thist is used for StrategyOutputVectorGenerator (see gostyle.py)
68 strategy_players = {
69 "territorial":[ 'Cho Chikun', 'Cho U', 'Suzuki Goro'],
70 "agressive":[ 'Kobayashi Koichi', 'Rui Naiwei', 'Yi Se-tol' ],
71 "careful":[ "Yi Ch'ang-ho", 'Ishida Yoshio' ],
72 "moyo":[ 'Takemiya Masaki', 'Cho Tae-hyeon'],
73 "attacking":[ 'Kato Masao', 'Nie Weiping'],
74 "flexible":[ 'Ma Xiaochun' , 'Yasuda Shusaku', 'Kuwahara Shusaku', 'Honinbo Shusaku', 'Go Seigen', 'Shao Zhenzhong' ],
75 "wild":[ 'O Meien', 'Miyazawa Goro', 'Wu Songsheng'],
76 "tesuji focused":[ 'Sakata Eio', 'Luo Xihe', 'Gu Li', 'Jie Li'],
77 "misc":[ 'Yoda Norimoto', 'Chen Zude' ]
80 ### Thist is used for PlanarOutputVectorGenerator (see gostyle.py)
81 player_vector = {
82 "Cho Chikun": [ 1.0, 0.0 ],
83 "Yi Se-tol": [ 0.0, 1.0 ],
84 "Yi Ch'ang-ho": [ 0.0, -1.0 ],
85 "Ma Xiaochun": [ 0.0, 0.0 ],
86 #"Honinbo Shusaku": [ 0.0, 0.0 ],
87 #"Go Seigen": [ 0.0, 0.0 ],
88 "Ishida Yoshio": [ 0.0, -0.5 ],
89 "Rui Naiwei": [ 0.5, 1.0 ],
90 "Sakata Eio": [ 0.5, 0.5 ],
91 "Takemiya Masaki": [ -1.0, 0.0 ]
94 ### Median year of player games
95 player_year = {
96 "Yoda Norimoto": 1998,
97 "Yi Se-tol": 2004,
98 "Yi Ch'ang-ho": 1998,
99 "Takemiya Masaki": 1988,
100 "Sakata Eio": 1970,
101 "Rui Naiwei": 2001,
102 "Otake Hideo": 1984,
103 "O Meien": 2001,
104 "Ma Xiaochun": 1995,
105 "Luo Xihe": 2001,
106 "Ishida Yoshio": 1982,
107 "Gu Li": 2005,
108 "Cho U": 2005,
109 "Cho Chikun": 1992,
110 "Yuki Satoshi": 2001,
111 "Yamashita Keigo": 2004,
112 "Takao Shinji": 2004,
113 "Miyazawa Goro": 1992,
114 "Kobayashi Koichi": 1991,
115 "Kato Masao": 1988,
116 "Hane Naoki": 2003,
117 "Fujisawa Hideyuki": 1975,
118 "Chen Yaoye": 2006
121 ### make dictionary from pairs of "strength name" and number of strengths scaled to -1 1
123 # gotta have list of one sized lists, because the dict has to have type string : [ number ]
124 # instead of just string : number
125 linear_list = [ [num] for num in Rescale(-1.0,1.0)(range(len(strength_all),0,-1))]
126 strength_linear_vector = dict(zip(strength_all, linear_list))
129 ### Following code consist of expert based knowledge kindly supplied by
130 ### Alexander Dinerstein 3-pro, Motoki Noguchi 7-dan and Vit Brunner 4-dan)
132 ### The vector at each name corresponds with
133 ### (Territory, Orthodox, Aggressiveness, Thickness)
134 questionare_vit_brun = {
135 "Chen Yaoye": (7, 5, 7, 6),
136 "Cho Chikun": (9, 7, 7, 9),
137 "Cho U": (4, 6, 7, 4),
138 "Gu Li": (5, 6, 9, 5),
139 "Ishida Yoshio": (6, 3, 5, 5),
140 "Luo Xihe": (8, 4, 7, 7),
141 "Ma Xiaochun": (5, 7, 7, 7),
142 "O Meien": (3, 9, 6, 5),
143 "Otake Hideo": (4, 3, 6, 5),
144 "Rui Naiwei": (5, 6, 8, 5),
145 "Sakata Eio": (6, 4, 8, 6),
146 "Takemiya Masaki": (1, 4, 7, 2),
147 "Yi Ch'ang-ho 2004-": (7, 6, 4, 4),
148 "Yi Ch'ang-ho 2005+": (7, 6, 6, 4),
149 "Yi Se-tol": (6, 5, 9, 5),
150 "Yoda Norimoto": (4, 4, 7, 3)
152 questionare_motoki_noguchi = {
153 "Cho Chikun": (8, 9, 8, 8 ),
154 "Cho U": (9, 7, 6, 8),
155 "Gu Li": (7, 8, 10, 4 ),
156 "Ishida Yoshio": (9, 6, 2, 6),
157 "Luo Xihe": (6, 8, 9, 7 ),
158 "Ma Xiaochun": (9, 6, 7, 8),
159 "O Meien": (1, 10, 10, 2 ),
160 "Otake Hideo": (4, 3, 5, 3),
161 "Rui Naiwei": (6, 6, 10, 2),
162 "Sakata Eio": (10, 5, 6, 10),
163 "Takemiya Masaki": (2,6, 6, 1),
164 "Yi Ch'ang-ho 2004-": (8, 3, 2, 3),
165 "Yi Se-tol": (5, 10, 10, 8 ),
166 "Yoda Norimoto": (8, 2, 2, 5),
167 "Fujisawa Hideyuki": (4, 8, 7, 4 ),
168 "Go Seigen": (8, 10, 9, 6),
169 "Hane Naoki": (8, 2, 4, 6 ),
170 "Honinbo Dosaku": (2, 10, 8, 5 ),
171 "Honinbo Shusaku": (8, 3, 2, 6),
172 "Honinbo Shuwa": (10, 8, 2, 10),
173 "Kato Masao": (2,3, 9, 4),
174 "Kobayashi Koichi": (8, 3, 3, 6),
175 "Miyazawa Goro": (1, 10, 10, 3),
176 "Takao Shinji": (4, 3, 7, 4 ),
177 "Yamashita Keigo": (2, 8, 10, 4 ),
178 "Yuki Satoshi": (2, 8, 10, 4)
180 questionare_alex_dinner = {
181 "Chen Yaoye": (5, 3, 5, 5),
182 "Cho Chikun": (10, 7, 5, 10),
183 "Cho U": (9, 5, 3, 7),
184 "Gu Li": (5, 7, 8, 3),
185 "Ishida Yoshio": (9, 6, 3, 5),
186 "Luo Xihe": (8, 10, 7, 4),
187 "Ma Xiaochun": (10, 6, 3, 9),
188 "O Meien": (4, 10, 9, 4),
189 "Otake Hideo": (5, 3, 3, 3),
190 "Rui Naiwei": (3, 5, 9, 3),
191 "Sakata Eio": (7, 5, 8, 8),
192 "Takemiya Masaki": (1, 9, 8, 1),
193 "Yi Ch'ang-ho 2004-": (6, 6, 2, 1),
194 "Yi Ch'ang-ho 2005+": (5, 4, 5, 3),
195 "Yi Se-tol": (5, 5, 9, 7),
196 "Yoda Norimoto": (7, 7, 4, 2),
197 "Chen Zude": (3, 8, 6, 5),
198 "Cho Tae-hyeon": (1, 4, 4, 2),
199 "Fujisawa Hideyuki": (3, 10, 7, 4),
200 "Go Seigen": (4, 8, 7, 4),
201 "Hane Naoki": (7, 3, 4, 3),
202 "Jie Li (USA)": (5, 3, 5, 4),
203 "Kato Masao": (3, 6, 10, 4),
204 "Kobayashi Koichi": (10, 2, 2, 5),
205 "Miyazawa Goro": (2, 10, 9, 5),
206 "Nie Weiping": (3, 7, 8, 4),
207 "Shao Zhenzhong": (4, 5, 5, 4),
208 "Suzuki Goro": (4, 7, 5, 5),
209 "Takao Shinji": (6, 4, 4, 5),
210 "Wu Songsheng": (2, 10, 7, 4),
211 "Yamashita Keigo": (2, 10, 9, 2),
212 "Yuki Satoshi": (4, 9, 8, 5),
213 "breakfast": (7, 7, 3, 4),
214 "rapyuta/daien": (4, 7, 6, 5),
215 "MilanMilan": (5, 5, 6, 4),
216 "roln111-": (6, 5, 7, 5),
217 "somerville": (4, 5, 5, 6),
218 "artem92-": (7, 4, 3, 2),
219 "TheCaptain": (3, 8, 7, 6)
221 questionare_list = [ questionare_vit_brun, questionare_motoki_noguchi, questionare_alex_dinner ]
222 questionare_total = questionare_average(questionare_list,silent=True)
224 def questionare_variance():
225 questionare_average(Data.questionare_list)
227 if __name__ == '__main__':
228 import sys
230 for arg in sys.argv:
231 if arg == '-p' or arg == '--all-players':
232 for p in Data.players_all:
233 print p
234 if arg == '-h' or arg == '--help':
235 print sys.argv[0], " [OPTIONS]"
236 print """
238 OPTIONS
239 -p, --all-players
240 prints a list of known players to the STDOUT.
241 -h, --help
242 help!