gnubg python scripting: gnubg.match ()

Use data from gnubg.match ()

Let's extract the match information from the analyzed file and extract the move or cude decision that had the error. I made it by referring to the sample in the scripts folder of 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)"

The execution result looks like this. That's about right.

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|                  |7 point match(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

Screenshot from 2016-07-09 21:13:31.png

No stats

The help displayed by help (gnubg.match) is supposed to contain statistics (stats), but I can't find it. I'm investigating, thinking that it might be possible to change the settings.

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']

to be continued

Recommended Posts

gnubg python scripting: gnubg.match ()
gnubg python scripting
gnubg python scripting: gnubg.findbestmove ()
gnubg python scripting: set threads
[Gimp] Start scripting in Python
Python