Extrayons les informations de correspondance du fichier analysé et extrayons la décision de déplacement ou de cude qui avait une erreur. Je l'ai fait en me référant à l'exemple dans le dossier scripts de gnubg.
def exportBad(baseName):
gnubg.command('load match ' + baseName)
m = gnubg.match()
for game in m["games"]:
print game['info']
for i, action in enumerate(game["game"]):
try:
analysis = action['analysis']
except KeyError:
continue
player = action['player']
action_type = action["action"]
skill = analysis.get("skill", None)
if action_type == "move":
cube_skill = analysis.get("cube-skill", None)
if skill:
print i, player, action_type, skill
if cube_skill:
print i, player, action_type, cube_skill, "(missed double)"
elif action_type == "take" or action_type == "drop":
print i, player, action_type, skill, "(wrong decision)"
Le résultat de l'exécution ressemble à ceci. C'est à peu près juste.
87027253.sgf
GNU Backgammon Position ID: AAAAzLvHAAAAAA
Match ID : 8ArgAIAACAAE
+13-14-15-16-17-18------19-20-21-22-23-24-+ O: nissis1953
| | | |OOO 8 points
| | | | OOO
| | | | OOO
| | | | OOO
| | | | OOO
v| |BAR| |Match à 7 points(cube: 1)
| | | |
| | | X X |
| | | X X X |
| X | | X X X X |
| X | | X X X X |1 point
+12-11-10--9--8--7-------6--5--4--3--2--1-+ X: faresss
{'points-won': 2, 'score-X': 0, 'winner': u'X', 'resigned': False, 'score-O': 0}
5 X move doubtful
16 O move bad
19 X move bad
20 O move doubtful
21 X move doubtful
25 X move bad
28 O move very bad
32 O move very bad
33 X move bad
36 O move very bad
37 X move doubtful
39 X move very bad
{'points-won': 2, 'score-X': 2, 'winner': u'X', 'resigned': False, 'score-O': 0}
1 O move doubtful
4 X move very bad
5 O move very bad
9 O move doubtful (missed double)
11 O move bad (missed double)
15 O move doubtful (missed double)
17 O move bad (missed double)
19 O move very bad (missed double)
21 O move bad
27 O move doubtful (missed double)
{'points-won': 1, 'score-X': 4, 'winner': u'O', 'resigned': False, 'score-O': 0}
1 O move doubtful
2 X move bad
3 O move bad (missed double)
5 O move doubtful (missed double)
7 O move bad (missed double)
8 X move bad
9 O move doubtful
9 O move bad (missed double)
11 O move bad (missed double)
13 O move bad (missed double)
15 O move doubtful (missed double)
{'points-won': 2, 'score-X': 4, 'winner': u'X', 'resigned': False, 'score-O': 1}
0 O move doubtful
3 X move bad
4 O move doubtful
5 X move bad
6 O move very bad
8 O move bad
11 X move doubtful
13 X move doubtful
15 X move doubtful
17 X move bad
18 O move doubtful
18 O move bad (missed double)
20 O move bad (missed double)
23 X move bad
24 O move bad
26 O move bad
40 O move bad
{'points-won': 2, 'score-O': 1, 'winner': u'X', 'score-X': 6, 'resigned': False, 'crawford': True}
1 O move doubtful
9 O move very bad
16 X move very bad
L'aide affichée par help (gnubg.match)
est censée contenir des statistiques (stats), mais je ne la trouve pas. J'enquête, pensant qu'il serait peut-être possible de modifier les paramètres.
In <6> > m = gnubg.match()
In <7> > games = m['games']
In <9> > type(games)
Out<9> > tuple
In <10> > game0 = games[0]
In <11> > type(game0)
Out<11> > dict
In <12> > game0.keys()
Out<12> > ['info', 'game']
à suivre