suragnair / alpha-zero-general

A clean implementation based on AlphaZero for any game in any framework + tutorial + Othello/Gobang/TicTacToe/Connect4 and more
MIT License
3.74k stars 1.01k forks source link

Add Othello player that can play with external programs using GTP #316

Closed plamentotev closed 2 months ago

plamentotev commented 2 months ago

GTP (Go Text Protocol) is a text protocol that allows Go (the game, not the programming language) programs to play with each other. Due to the similarity in the board representation the protocol is used by Othello/Reversi programs.

Add Othello player that uses the protocol to play with external programs. That makes it easy to test how well the AI performs against other AI bots.

Add some additional methods to the Player interface - startGame, endGame and notify. Those methods are essential to keep the state synced with external program.

Update Arena to use those methods if present to keep it backward compatible and not to force other implementations to implement class. To this end GTPOthelloPlayer is callable so that players can still be a simple function.

Using the player in pit.py is pretty straightforward:

player2 = GTPOthelloPlayer(g, ["/path/to/bin/Egaroucid_for_Console", "-gtp"])

I've tested it with Egaroucid and Edax

suragnair commented 2 months ago

thanks for the contribution, this looks great. Can you please add your handle in the main README under Contributors and Credits. And can you add a README in the othello directory with a brief note about GTP and how to interface with it. Thanks again!

plamentotev commented 2 months ago

thanks for the contribution, this looks great. Can you please add your handle in the main README under Contributors and Credits. And can you add a README in the othello directory with a brief note about GTP and how to interface with it. Thanks again!

Done. And thanks for the great Alpha Zero implementation.