Chapter 12. Rules

Table of Contents

Menubar
Requirements
End

By default, GoGui deals with GTP engines that play the game of Go, but it can support other games if the GTP engine implements additional extensions to the protocol. These extensions lets the GTP engine determine the board configuration after a move is played, the list of legal moves, and the game result when the game is over. This way, it is possible to use GoGui to play games such as renju, gomoku, or Othello.

The ruler program must indicate the command it supports with list_commands.

Menubar

Attach

Start a program from the list of ruler programs and synchronize it to the current game at the current position. If a ruler was already attached, it will be terminated, before the new ruler is started. If the ruler is for a game different from its predecessor, the position is cleared from the ruler's initial position (called by gogui-rules_board).

Detach

Terminate the currently attached ruler program.

New Program

Add a new ruler program. The name field should contain a label for the Attach menu. The command field should contain the command to run the ruler program.

Edit Programs

Edit the list of available ruler programs.

Requirements

A ruler program must support the followin commands:

gogui-rules_game_id
The response of the command is a string that specifies the game that is managed by the GTP program. It must begin with an uppercase letter and then contain only lowercase characters. Example :
gogui-rules_game_id
= Othello
gogui-rules_board
The response of the command is a board of string containing '.' for an empty intersection of the Goban, 'X' for a black stone or 'O' for a white stone. Other characters are ignored. This command will be used to display the board in GoGui. Example :
gogui-rules_board
= . . . . . . . . .
  . . X . O . X . .
  . X . . . . . . .
  . . O . . . . O .
  . . . . . . . O .
  . O . X . . O X .
  . . O X . . . X .
  . X O . . X O X .
  . . . . . O . . .
gogui-rules_board_gfx
The response of the command is a gfx analyze command string. It can be used to display game-specific graphics on the board. For instance, a chess program can use this command to display square colors and piece labels.
gogui-rules_captured_count
Number of stones captured for each player. The output of this command is two integers, separated by a space. The first number is the number of stones captured by Black, and the second number is the number of stones captured by White. Example :
gogui-rules_captured_count
= 0 1
gogui-rules_board_size
The response of the command is a string containing an integer that specifies the board size of the game. The board in GoGui will always be non-resizable when a ruler program is attached. Example :
gogui-rules_board_size
= 15
gogui-rules_legal_moves
Possible move list command for the current side to move. The command is used to determine the moves that the player will be able to play (otherwise, an illegal move message will be sent). The command result must necessarily be a string of the following syntax : "A1 B9 C5 C6 pass". The character 'I' must not be used. The 8th letter is 'H' and the 9th letter is 'J' like in the Go standards. Numbers start with 1 instead of 0. Pass must appear in response to this command if the player is allowed to pass. If no move is possible, the game ends. Example :
gogui-rules_legal_moves
= A1 A2 A3 A5 A6 A7 A9 B1 B2 B4 B5 B6
  B8 C1 C2 C6 C7 C8 D2 D4 D5 D7 D8 E1
  E2 E4 E6 E7 F6 F8 F9 G2 G3 G5 G6 G7
  G8 H1 H5 H6 H9 J1 J3 J4 J5 J7 J8 pass
gogui-rules_side_to_move
The command must return a string beginning with 'b', 'w', 'B' or 'W' . Example :
gogui-rules_side_to_move
= white
gogui-rules_final_result
The result of this command is a string that will be shown in a dialog box when the game is over. This is the only way to notice about the game result when a ruler program is attached since the Score menu is disabled. Example :
gogui-rules_final_result
= White wins by 4 points. Final score
  is B 30 and W 34.

End

The game ends if the response to the command gogui-rules_legal_moves is an empty string.

Then, GoGui queries the score to the ruler program with gogui-rules_final_result and shows the result string in a dialog box.