OGS SGFs have brackets

When I download sgfs from ogs they have this nested structure and leave a lot of trailing brackets at the end. And I don’t like :frowning:

I know this doesn’t matter. But I scream internally every time I open sgf like this.



Oh god. This is definitely a bug and not how SGFs should be composed. The whole point of the semicolon prefix character is to avoid all of these needless parentheses, which become unnecessary in game records without variations.

1 Like

That’s not an SGF, that’s the end of my Lisp program :stuck_out_tongue:

1 Like

It’s easier to implement the export this way.

It would be even easier to implement export as returning a blank file.

The problem is that the current behavior does not conform to the SGF standard, which could cause problems in some SGF editors and other tools, thus defeating the purpose of exporting the game records at all. While some SGF editors may be able to handle these incorrectly formatted records, it’s still not a good idea to break those that require input to follow the standard.

Years ago, I had looked at SGFs exported from OGS to address other bugs, and back then this specific issue did not exist. Hence, it seems that already it was implemented correctly in the past.

 Collection = GameTree { GameTree }
 GameTree   = "(" Sequence { GameTree } ")"
 Sequence   = Node { Node }

It confirms the document you linked. A GameTree is not defined as

GameTree = (  "(" Sequence ")" | "(" Sequence GameTree GameTree {GameTree} ")" )

It’s not ideal, but it complies the standard.

The use of needless parens is not excluded by the EBNF (in Section 2 of the page that you linked), however, Section 1 of that same page and this other page that further elaborates explains how the game tree should be represented in SGF format, which is to remove the needless parentheses.

It should be noted that complying with the EBNF is only part of complying with the standard. There many other rules that are spread across various pages.

According to the syntax checker our export is OK. No errors, no warnings.


I’m gonna tag @anoek in this since he’s 1. the only person who can change it, and 2. the only person who knows why it was implemented that way in the first place (and whether or not it was deliberate or a bug)

1 Like

Interesting, I guess that suggests that it is only a matter of style then.

I think nearly every other editor will generate SGFs with the parentheses removed. Earlier, you gave ease of implementation as a reason to have extraneous parentheses, however, I find that reason dubious, since it is very easy not to insert those parentheses in the first place.

About 5 years ago, it was not implemented this way. I know since I was looking at SGFs generated by OGS and reporting some bugs. I guess this change must have happened at some point after that.


I believe anoek was recently working on a bug to do with exporting AI analysis… it could have entered at that point possibly?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.