File tree 1 file changed +20
-4
lines changed
1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change 53
53
54
54
55
55
APP_NAME = 'Python Easy Chess GUI'
56
- APP_VERSION = 'v0.75 '
56
+ APP_VERSION = 'v0.76 '
57
57
BOX_TITLE = '{} {}' .format (APP_NAME , APP_VERSION )
58
58
59
59
@@ -245,15 +245,31 @@ def get_book_move(self):
245
245
246
246
def get_all_moves (self ):
247
247
is_found = False
248
+ total_score = 0
249
+ book_data = {}
250
+ cnt = 0
251
+
248
252
if os .path .isfile (self .book_file ):
249
- moves = '{:5s} {:<} \n ' .format ('move' , 'score' )
253
+ moves = '{:4s} {:<5s} {} \n ' .format ('move' , 'score' , 'weight ' )
250
254
with chess .polyglot .open_reader (self .book_file ) as reader :
251
255
for entry in reader .find_all (self .board ):
252
256
is_found = True
253
257
san_move = self .board .san (entry .move )
254
- moves += '{:5s} {:<}\n ' .format (san_move , entry .weight )
258
+ score = entry .weight
259
+ total_score += score
260
+ bd = {cnt : {'move' : san_move , 'score' : score }}
261
+ book_data .update (bd )
262
+ cnt += 1
255
263
else :
256
- moves = '{:5s} {:<}\n ' .format ('move' , 'score' )
264
+ moves = '{:4s} {:<}\n ' .format ('move' , 'score' )
265
+
266
+ # Get weight for each move
267
+ if is_found :
268
+ for _ , v in book_data .items ():
269
+ move = v ['move' ]
270
+ score = v ['score' ]
271
+ weight = score / total_score
272
+ moves += '{:4s} {:<5d} {:<2.1f}%\n ' .format (move , score , 100 * weight )
257
273
258
274
return moves , is_found
259
275
You can’t perform that action at this time.
0 commit comments