Cmput 455 - sample session with the Go1 python program

Setup

First, make sure you do the activities to set up Python, GoGui, and download the go.tgz file with the code. Go into directory go. It contains a set of Python 3 files, which implement the Go0 and Go1 programs from the lecture. You can run programs either from the command line, or with a GUI such as GoGui, which understands GTP.

Command-line Sample Session

Change into the go directory and start the program with either

./Go1.py
or
python3 Go1.py

If ./Go1.py gives you trouble, check Permissions and Python Path below.

Then execute the following GTP commands and observe the answers, which all start with a string "= ".
For example, boardsize has no output (other than the "= " at the start of each reply), but it sets up the size of the program's board.
showboard prints a (primitive) image of the board with the usual encoding.
play needs a color argument 'b' or 'w' followed by the coordinates of your move.
legal_moves needs a color argument 'b' or 'w', and returns the list of legal moves in sorted order.

boardsize 3
= 

showboard
= 
[[0 0 0]
 [0 0 0]
 [0 0 0]]

play b a2
= 

showboard
= 
[[0 0 0]
 [1 0 0]
 [0 0 0]]

play w a1
= 

showboard
= 
[[2 0 0]
 [1 0 0]
 [0 0 0]]

legal_moves b
= a3 b1 b2 b3 c1 c2 c3

quit
= 

% 

To avoid typing, you can also download all these commands in a text file sample-session.gtp and pipe them into the program. But you will not see the results step by step.

./Go1.py < sample-session.gtp

Permissions and Python Path

Sample Session with GoGui

While it is not strictly necessary to use a graphical user interface to a GTP-based Go program, it is more intuitive.

Add a player in GoGui

  1. Open GoGui
  2. From menu item "Program", choose "New Program..."
  3. In the dialog window, choose the path to your player. Use the full path such as mydirectoryname/go/Go1.py
  4. If this fails, read Permissions and Python Path above, or specify both the full path to your python3 AND your program, separated by space, e.g. crazypythonlocation/python3 mydirectoryname/go/Go1.py
  5. Choose a label for your player. In the future, you can use "Program" - "Attach" to select this player by this name.
  6. You can leave the "Working directory" empty.

If this succeeds, you have now connected your program to GoGui, and are ready to play, analyze, etc. If this fails, you should check the error message. Then you can edit your command in "Program" - "Edit Programs...".

You can add as many programs as you like, for example Go1, Go2, ..., or any free Go programs you find on the internet that speak GTP.

Play a Game in GoGui

Some errors and how to fix them