This page looks best with JavaScript enabled

European Go Championship 2021

· ☕ 4 min read · ✍️ Bart

photo credits: Photo by Joe Woods on Unsplash

Visualization of the European Go Championship’s Finals

Motivation

Just a few days ago the world chess championship ended. Of course, it is a very important event that always appears in the media. FivethirtyEigth is no exception. I am not a big fan of chess (I practiced it in my high school days, but I never spent enough time to be competent at it), but like any other sporting event, I find it fascinating to keep up to date with what is going on. The FTE coverage was very interesting and in particular I found the viewing of the games very engaging. In it, they visualized the stockfish AI’s evaluation of the game.

Just at that time, something that was happening that perhaps did not receive so much publicity, was the European Go championship. It’s been a couple of years now (covid world phase) that I don’t play Go actively, but it is still a game that I love. And precisely for this reason I thought of repeating the visualization of the good people of FTE but in the Go championship. A little to practice visualization (I considered it an interesting challenge) and another because offering that analysis could make someone understand the games a little better.

Analyzing Games

To analyze the games I used KataGo an AI with some interesting extras. As of January 2021, KataGo is one of the strongest open source Go bots available online. KataGo was trained using an AlphaZero-like process with many enhancements and improvements, and is capable of reaching top levels rapidly and entirely from scratch with no outside data, improving only via self-play. Normally I used katago as a powerful AI to play against the machine. However, it can also be used to analyze games, and it is something that is being incorporated in the websites specialized in playing Go online. It is interesting to note that it is very likely that for the average player the variations offered by KataGo are not entirely recommendable, since a good review requires understanding what is being done (the direction and sense of play). Even so, the KataGo analysis allows to evaluate both the probability of victory and the difference in the estimated score of both players.

To launch this analysis, you can use the raw version of Katago directly from the terminal. But as I had in mind to analyze several games, I found this repo: analyze-sfg

analyze-sfg allows you to launch the katago analysis mode for several games. This mode returns a sgf file (the standard for storing go games) in which the different probabilities of each player and the variations suggested by KataGo are commented. With this I had everything to generate the graphs.

How to read SGF files

The next step was to find (or so I wished) a pyhton library that would allow me to work with sfg files. Luckily for me there was something ideal: https://mjw.woodcraft.me.uk/sgfmill/
SGFMill was more than I needed for the job, so by testing which nodes and which properties would lead me to the information I needed, I got a list with the evolution of the game (odds and score) and information about players, title etc.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import re
from sgfmill import sgf
with open("roln90_vs_artem92_04_12-analyzed.sgf", "rb") as f:
    game = sgf.Sgf_game.from_bytes(f.read())
winner = game.get_winner()
board_size = game.get_size()
root_node = game.get_root()
b_player = root_node.get("PB")
date = root_node.get("DT")
w_player = root_node.get("PW")
analsyiss_comments = root_node.get("C")

mov_list =[node.get_move() for node in game.get_main_sequence()]
comment_list=[node.get("C") for node in game.get_main_sequence()]

for node in game.get_main_sequence():   
    movimiento = node.get_move()
#    print(movimiento)
    comment = node.get("C")


data_percentage=[]
for s in comment_list: 
    info = s.split('*')
    if s[0]!='#' and len(info)>1:
        if re.search(r' Win rate: (.*?) ', info[1]).group(1) == 'W':
            win_rate = re.search(r' Win rate: W (.*?)%', info[1]).group(1)
            number = float(win_rate)
            data_percentage.append(number)
        if re.search(r' Win rate: (.*?) ', info[1]).group(1) == 'B':
            win_rate = re.search(r' Win rate: B (.*?)%', info[1]).group(1)
            number = float(win_rate)
            data_percentage.append(100-number)
data_percentage_score=[]
for s in comment_list: 
    info = s.split('*')
    if s[0]!='#' and len(info)>1:
        if re.search(r' Score lead: (.*?) ', info[2]).group(1) == 'W':
            win_rate = re.search(r' Score lead: W (.*?)\n', info[2]).group(1)
            number = float(win_rate)
            data_percentage_score.append(number)
        if re.search(r' Score lead: (.*?) ', info[2]).group(1) == 'B':
            win_rate = re.search(r' Score lead: B (.*?)\n', info[2]).group(1)
            number = float(win_rate)
            data_percentage_score.append(-number)

The results (Divided by game)

First I try with the Quarterfinals game:

Quarterfinals

Meanwhile 1st and 2nd matches of the final were played:

Finals's 1 game
Final's 2 game

The complete infography

And then, I mixed both of them and make a final full infography of the whole Final:

Both games

I need to update this, sorry!

Share on

Bart Ortiz
WRITTEN BY
Bart
I ask myself a lot of questions.