How to interact with gnu go with gtp by JavaScript or Python

Hi, this is not quite an OGS api question. I apologize for it but I hope someone can help me. I learned that gtp is a protocol to communicate with a go server, either online or local. Can someone recommend a library in either JavaScript or Python that is a wrapper of gtp? I don’t need to play with an AI. All I want is to have two players play locally. I believe that is possible but not sure where to start. Any guidance is appreciated.

1 Like

I found SabakiHQ / go-board to be pretty close to what I need if my understanding is correct. I am still trying to understand the normal workflow of using this library. Does anyone here have experience using it?

I remember there was a person that wrote a book about making go ai, and had a section about connecting a bot to OGS to play against, it’s all in python I think.

The GitHub has some ideas of using gtp with the bots

I think this was recommended for connecting a bot to OGS

That seems to be javascript/typescript.

It’s something I was curious about but haven’t dug into.

Oh that is cool!! Thanks for the links. I am looking for ways to programmatically play go locally so it’s not quite the same but these will be useful when I implement AI in my project :grinning:

Could you explain why you need GTP for this? It seems like if both players are “local” then they could play on the same program and no need for a text protocol?

To be very honest, I don’t know if I need GTP. I am not entirely familiar how it is normally used. I wanted to use it because I thought it’s an easy way to have a program tell me what would happen when I place a stone somewhere on the board. I don’t want to have to code that program myself. However, I discovered Sabaki go board module. This seems to be exactly what I need to update board status and fetch board information.

1 Like

I think GTP is very useful when you want to interface with other programs, but you aren’t sure what the other programs are.

That’s why it’s used a lot for AI. For example, GnuGo has a very basic UI, but since it supports GTP, it can communicate with more advanced user interfaces like Sabaki without knowing a Sabaki-specific API.

So basically if you have a program that people should interact with, you either provide api or be compliant with gtp. Is that right?

Hmm maybe indirectly, but I’d say GTP is mostly useful when you have a program that you want to interact with other programs. Like GnuGo <-> Sabaki or GnuGo <-> OGS or Lizzie <-> LeelaZero