Extrahieren wir die Übereinstimmungsinformationen aus der analysierten Datei und extrahieren die Entscheidung zum Verschieben oder Schließen, bei der ein Fehler aufgetreten ist. Ich habe es gemacht, indem ich mich auf das Beispiel im Skriptordner von gnubg bezogen habe.
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)"
Das Ausführungsergebnis sieht so aus. Das ist ungefähr richtig.
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 Punkte
| | | | OOO
| | | | OOO
| | | | OOO
| | | | OOO
v| |BAR| |7 Punkte Match(Würfel: 1)
| | | |
| | | X X |
| | | X X X |
| X | | X X X X |
| X | | X X X X |1 Punkt
+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
Die von help (gnubg.match )
angezeigte Hilfe soll Statistiken (Statistiken) enthalten, kann aber nicht gefunden werden. Ich untersuche und denke, dass es möglich sein könnte, die Einstellungen zu ändern.
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']
Fortsetzung folgt