What is the name of the program that keeps the state of go game but not the ai itself

Hi I have a question about these programs that can track what stones are in the board, where the stones have been placed, how many dead stones for each player and branch information.

This is not the go engine if I understand it correctly. Go engine is more like the ai that knows where to place the next stone based on the current state of the game and interfaces with these go game programs

What is the name of such program and does anyone know where to find an implementation of such programs in Python?

I believe they’re called “sgf viewers” or “sgf editors” if they allow branch editing. (SGF = Smart Game Format, it’s a text file with a modified extension .sgf, essentially the standard to store a go game transcription digitally)

As far as Python programs go, I believe KaTrain is mostly written in Python, though its main purpose is to interface with katago (the katago program and network come bundled with the releases).

1 Like

Hmm sgf viewer doesn’t sound like it actually tracks moves and validate moves though. Would be nice for it to be something like Sabaki’s backend programs which tracks current board, dead stones, and liberty info.

Is there a way to send individual move strings to Sabaki and somehow query all other game info from Sabaki programmatically??

I’m not sure, but maybe GitHub - SabakiHQ/gtp: A Node.js module for handling GTP engines. is what you’re looking for.


Undoubtedly there exist many software implementations to maintain the board state and game state of a game of go. But I expect that most of those implementations are an integral part of some other go-related software (sgf editors, KaTrain, Lizzie). And I assume it is often created from scratch by the programmer of that larger piece of software, with some tailor made “interface” to support the specific functionality of that larger piece of software

So I don’t know what you intend to make, but you may have to write the software to maintain board state and game state yourself. Though you can probably find useful tips and examples with some help from google.

Such as: Implementing the Game of Go (Part 1)


That sort of thing is usually done using Go Text Protocol (GTP): Go Text Protocol at Sensei's Library


Cool thanks guys!

1 Like

SGF viewer/editor software usually inherently tracks the board state and validates moves to process captures, in order to display the board state on some sort of interface. Usually, such software also keeps track of (or calculates) how many stones have been removed at any given point in the game tree and displays that on the interface as well. A lot of SGF editors might also validate moves against at least a basic ko rule, suicide prohibition, and basic illegal moves (like placing on top of an existing stone), however, some SGF software will allow those rules to be manually overridden since actually the SGF standard allows such illegal moves to be recorded. I don’t know any software that explicitly tracks liberties, but rather that just be checked within a subroutine to determine captures.

As @gennan mentioned, representation and implementation of the basic game state and game mechanics is usually just an integral part of a larger program to do a more specific task (like SGF editing, game playing, AI engine, etc.) and such representations and implementations are usually custom tailored to make those tasks easier.

I don’t know of any specific python library to do what you specifically want, but it is likely that it might exist. However, it should be quite easy to find many examples of Go related software that would inherently involve a submodule to handle the game state and rules. Here is one particular piece of software:

This is actually a minimalist Go AI engine (employing a basic Monte Carlo tree search, i.e., the classic approach in the pre-AlphaGo days) written entirely in only 1185 lines of Python. It might be useful to look at that code to get an idea of how game representations and logic are handled, and it might be possible to extract a minimal Python implementation from there, by discarding the AI engine parts.

1 Like

Thanks! This is looking really great. I have another question. Lets say instead of python I use JavaScript. I know Sabaki has a gtp submodule that allows the creation of engine and controller: GitHub - SabakiHQ/gtp: A Node.js module for handling GTP engines.

My assumption is that I can create an engine with it waiting for interaction requests. Do you know how to interact with this engine??

If it’s using GTP, does it matter what language you use? I assume it would be communicating via a network socket or something…

1 Like

The language probably doesn’t matter but I want to use one single program to both create a gtp engine and create a client that sends commands to that engine. Sabaki gtp seems to be able to create an engine but I don’t know how to interact with the engine programmatically yet.

1 Like

IME those 2 parts (gtp engine and gtp client) would be 2 separate processes communicating via some text stream (pipe/stdin/stdout/…). This type of interprocess communication allows you to develop and run both parts separately, quite possibly written in different languages and running on different operating systems. This allows for some flexibility in swapping out those parts, instead of having one monolithic app. There already exists a lot of tooling based on this gtp mechanism.
For example, the gtp engine can be a console app, while the gtp client can be some windows app with a local UI, or a go server (such as OGS) acting as a gtp client with a remote UI for a human opponent, or a computer go server acting as an interface between 2 bots playing.
In the past I have used GoGui as a gtp client to translate user actions to gtp commands and sending those to my locally running gtp engine. You can set it up to run your gtp engine or any other gtp engine via the command line. Sabaki offers similar options.

I feel there is some misconception here. If you’re using Sabaki or some other gtp client, it already takes care of the gtp communication with your gtp engine. For example, when the user clicks on the board in the UI, Sabaki sends a gtp command (in plain text) to the gtp engine, corresponding to that user action, such as “move white D4” (see gtp specs).

If you’re writing your own gtp client, it should translate user actions to gtp commands and send those to the gtp engine.

Which part do you intend to write yourself? The gtp engine or the gtp client, or both? Can you perhaps describe in more detail what you’re trying to accomplish?


There are a bunch of JavaScript libraries for Go listed here

Thanks for the explanation! I am trying to write a program that takes user input from the two players. They would input something like AB or PF to indicate where on the board they want to place their stone. I attempted to write my own go engine but there are two many things to keep track so I thought it is better to use an existing go engine instead.

Based on what you said, what I want to build is really the gpt client that translate such user input into gtp commands that can be fed into a gtp engine. That being said, I only found resources on the internet that teach me how to write a gtp client for Sabaki where user enter input directly inside Sabaki’s terminal. I have yet to find some kind of tutorial that explain how I might send commands into Sabaki from another program.

Sabaki already is a gtp client, where a player (or 2 players) can enter their moves. It sounds as if you want to want to build your own gtp client and use Sabaki as a gtp engine, but I don’t think that’s how it works.

If the players are sitting at the same computer, they can already play a game using a gtp client such as GoGui or Sabaki.

Note: a gtp engine can also be a go engine, but it doesn’t have to be. A limited gtp engine (without a go engine inside) just won’t support some go engine related gtp commands, such as “genmove”.

That’s more like a description of how you intend to accomplish your goal, but I still don’t understand exactly what your goal is (which it is not already supported by existing tools).


It’s related to a project I am working on. It connects a go board to a pc. And I want to use Sabaki to validate and track the progress of a game. I built a 9 by 9 board prototype and it is able to transmit stone placement data into a software I wrote. The prototype uses OGS to actually play the game and displaying the progress but I want to have the offline capability as well.

What I want to do is to send placement data like AB to Sabaki and require Sabaki to treat it as if a player has clicked on its board at that location. So basically instead of waiting for a mouse click event, Sabaki would wait for a placement data to arrive to indicate where the stone should be played. Does this make sense?


I think I understand.
I suppose you could then wrap your software inside a gtp engine, masquerading as a go engine. Except the moves don’t come from some AI, but from your automated go board. Sabaki would then send commands to your gtp engine to generate a move and wait until your gtp engine returns the move that was played on your physical board.
Does that make sense?

1 Like

I guess I got it. To Sabaki, my software would work like an AI program, except that normally Sabaki would wait for the AI algorithm to finish computing the next move but in my case Sabaki would wait for the player’s next move. Is that right?

1 Like

By the way, do you happen to know how building an engine work?