mgt — game record display/editor for the oriental game of go


mgt [-m filename] [-s] [-t] [files]


Go is an ancient oriental strategy game based on the capturing of territory. The players alternate putting stones on the board, trying to surround as many empty intersections as possible.

Mgt allows the user to examine Go game tree files created through the Macintosh(tm) programs Smart-Go (tm) or Go Explorer (tm). Mgt also has basic Go game tree editing capabilities and may be used to create or edit game tree files. The on-line material provided by a rather extensive and growing database allows many hours of instructional enjoyment of various studies and tutorials concerning the game of Go.

Mailgo is a utility which manages E-mail Go games using mgt as the Go board editor. It is included in the mgt package.

The mgt program was originally developed to be a companion for the series, "From My Go Teacher", archived for ftp. Also available is the Internet GO Board communications program, 'go', also by Greg Hale, which connects up two terminals in real-time anywhere in the world, and the clients for the Internet Go Server.

Command line options

-m filename
Invoke a set of options used by the mailgo program for managing email games. If a filename is specified for loading (see below), the game record is loaded, and mgt automatically moves to the end of the main variation of the game record. The game can be modified without confirmation. If the game record has been modified, it will be automatically saved, on exit, to the filename specified after the -m and mgt will return success (zero). If the game record has not been modified, or has not been allowed to be saved, then mgt will return failure (nonzero).

Change save format used to write save files. The default save format is the long format Smart-Go file. Using this option results in short format Smart-Go files.

Invoke tutor mode where you select variations by playing on the board. The key for making a move has special behavior in this mode. See the section on the "space or 0" keyboard command for a description.

These are the files to be loaded. The Unix and IBM version support wildcards. If no file is specified, mgt loads a blank board. If you attempt to modify a file that was loaded, mgt will prompt for confirmation the first time.


Mgt can be used to view and edit game records, or as an electronic game board for a two person game. There are many keyboard commands which execute the various editing and display functions.

Step down the game tree to the next move. Stop at the end of a variation and do not visit other variations.

Move back up the game tree. (Previous move)

Go to the next node using a tree traversal which will visit all nodes. Sometimes the order of traversal can be confusing.

Go to the previous node -- the opposite of "." forward movement.

Go to end of the current variation.

Go to beginning of the game tree.

Go forward like the "." command until a comment.

Go backwards like the "," command until a comment.

Go to a specified node. Type in the desired node number.

Move forward until there is a variation branch in the game tree.

Move backwards until there is a variation branch in the game tree.

k and i
Scroll the game tree variation window up and down. A - at the top of the variation window, and a + at the bottom indicate that more variations are available.

j and u
Scroll comment window up and down. A - at the top of the comment, and a + at the bottom indicate that more comments are available.

Load new file. Will prompt for confirmation if the current file has been modified.

Load previous file. (Reverse through the file list)

Load next file. (Forward through the file list)

Write out Smart-Go file. Will prompt for a filename. The special filename * will save with the current name (which appears in the upper right corner).

space or 0
Make a move. The current player turn is indicated by the > < around the captured stones on the lower right. Normally, this adds the move to the game tree and moves to a new node. In tutor mode, it checks the various game continuations. If one of them contains the move you made, it moves to that variation. If not, it prints an error message. The game tree cannot be modified in tutor mode.

Pass. Enter a pass move.

Toggle stone color. Changes whose turn it is without adding any tokens in the game tree. This will not work if the game tree has a PLayer token (generated by the o key) at the current node.

Set/unset black stones.

Set/unset white stones.

q or ESC.
Quit. q will prompt for confirmation. ESC will not prompt for confirmation.

Create a variation below the current node. The variation will initially contain a null node. You must move to that variation to make a move in it. If the "v" command is invoked at a node which is at the end of a variation, variation "A" is created with a null node. Subsequent invocations of the "v" command will create the "B", "C"... variations.

Cut tree. Moves the current node and everything below it to a temporary holding buffer. (Moves your location back to the parent of the node you are one when you invoke it.)

Paste tree. Pastes the temporary holding buffer in after the current node. Usually the opposite of cutting the tree.

Edit the current comment. The editor has two models of operation. The default model has been vaguely designed after emacs. That means that the editor commands are either 'control-key' or 'escape-key'. The controls are configurable through an environment variable. The notation "^key" is used to indicate control keys, and "]key" is used to indicate keys which should be preceeded by the escape character.

On some terminals, instead of ESC-key, you can press Alt-key or Meta-key. (On the IBM version, you can use the Alt key.) Under VMS, the ESC key does not work. VMS users may need to redefine the edit keys.

The second edit model was vaguely designed after vi. That means that the editor has a command mode for cursor movement, etc. and an insert mode for inserting text. The vi model editor starts in insert mode. The ESC key changes mode from insert mode to command mode. If pressed in command mode, the ESC key exits the comment editor and saves the comment. The letters below are typed in command mode to obtain the specified function. To leave command mode and enter insert mode, you must use the function which is listed as the insert mode command. This defaults to 'R'. To select the vi like mode of operation, put _ASCEDVI in your MGT environment variable.

Defaults are:

       Command                emacs   vi
cursor up    (previous line)  ^P      k
cursor down  (next line)      ^N      j
page up      (prev page)      ]p      ^B
page down    (next page)      ]n      ^F
cursor left  (back)           ^B      h
cursor right (forward)        ^F      l
beginning of line             ^A      0
end of line                   ^E      $
beginning of comment          ]<      H
end of comment                ]>      L
delete one character          ^D      x
delete to end of line (kill)  ^K      D
toggle insert mode            ^I      R
save comment                  ]z      w
exit, don't save comment      ^W      q

Pressing c on a comment larger than the 120 lines allocated for comments will cause the extra to be lost. Also, on terminals which generate IBM PC arrow key codes, the arrow keys will correctly move the cursor within the comment editor. The arrow keys only work in the emacs based model.

Delete node. Deletes the current node, replacing it with its child. If the current node has no child, then clear the properties of the current node.

Name the current node. You will be prompted for the name.

Score the game. After selecting this, move the cursor around and remove the dead groups with 0 or space. You can undo one (and only one) kill with the u key. Pressing return will score the game and print the (Japanese) score in the comment area. If you missed some dead groups, continue removing them. Press q when you wish to exit scoring mode. You will be prompted to either keep the score information as a comment for the current node or restore the old comment.

Enter info mode. In this mode, the various informational properties of the current file are displayed and may be edited. To edit an item, press the letter associated with it, and enter the new text. This letter must be entered in upper case. To see a list of letters, press ?. The comment window scrolling keys can be used to scroll the info display. The supported info properties are: Size, Handicap, playerBlack, bLackrank, playerWhite, whIterank, Gamename, Event, rouNd, Date, Place, Time, Result, gameComment, sOurce, User, Komi. The capital letters in this list indicate which letter selects that info property.

Toggle tutor mode. (See the section on space or 0 for explanation.)

Toggle the format used for writing Smart-Go files between long and short.

Refresh the screen.

Save the current screen to a file.

Display a help screen.

Move the cursor around. Assumes standard numeric keypad orientation.

Environment settings

All of the characters used for the commands and the display are configurable via environment variables. For the ascii interface, use:

.nf setenv MGT '_ASCCOM:q><.,eb}{][gwzxv\!lm#^cdn
            _ASCINV _ASCED:PNpnBFAE<>DKIzO'
       (command should appear all on one line with a 
        single space separating _ASC... from the
        previous string.)

to get the default characters. (This is csh syntax. For other shells, the syntax will be different.) Place this line in your .cshrc so the alternate characters are always in effect.

The _ASCCOM string allows you to change the keyboard commands. Upper case letters stand for control characters.

The _ASCCHAR string specifies the display characters. For example, to use @ for black stones, change the # to @ in the _ASCCHAR string. You need only include one of the two declarations ("_ASCCOM:" or "_ASCCHAR:") if you only want to change the commands or characters but not both.

To set the default display type to inverse video, use _ASCINV in the MGT environment variable.

To set the comment editor commands, use _ASCED in the MGT environment variable.

For the _ASCED environment variable setting in the emacs based editor model, control keys are specified with a capital letter, and ESC keys are anything which is not a capital letter. This is the key string for the defaults: PNpnBFAE<>DKIzO. Note that ^V, ^O, ^C and ^Z are poor characters to use for anything if you have berkeley unix because the berkeley tty drivers interpret these characters. The ^V character is the quoting character which quotes the following character. You will need to press it twice for mgt to see it. The other characters have to be quoted by first pressing ^V or mgt will not recognize your keypress. You cannot use ^H or ^? for anything because the editor always interprets these as destructive backspace.

For the _ASCED environment variable setting in the vi based editor model, no special processing is done on the characters. In order to specify control keys, you must place actual control characters into your environment string. The default string has two control commands (^B and ^F) defined. This is the default: kj^B^Fhl0$HLxDRwq. The vi based editor model may be selected be including _ASCEDVI in the environment variable.

If you wish to include control characters in your string, you can do this most easily by editing a file which sets the environment. Vi can insert most of the control characters directly.

In all cases, when you set your own keys, you must set all of the keys, and they must appear in the correct order. If you give assign the same key to different functions, then an arbitrary one will be used by mgt and the other functions will be unavailable. If multiple contradictory specifications occur in the mgt environment variable, the last that appear will be used by the program. Any option not specified will assume the default values identified above.

With the IBM version, the same effects may be achieved under DOS 4.0 or DOS 5.0 with a SET command placed in the AUTOEXEC.BAT file. Under previous DOS versions, quotes were interpreted literally and "|", ">" and "<" characters have special meanings and thus cannot be put into environment variables with the SET command.

Under VMS, the command is just MGT = "_ASCCHAR:..."

Comment formatting

Comments are expected to consist of long lines, each of which is one paragraph. A single long line will be formatted to fit the display. Line breaks will be ignored if they are preceeded by a space, but will be respected otherwise.


All displays have in common the purpose of displaying a go tree.

ASCII display:
    A B C D E F G H  S T
   +---------------  ---+   -Suppose this is the second
 19|. . . # . . . .  . .|19| line of the comment.  Since
 18|. O O # # # O .  . .|18| there is some more of the
 17|. # # O O O O .  . .|17| comment above us unseen, 
 16|. # O + . . . .  . .|16| the - appears to the left
 15|. # O . O . . .  . .|15| of 'Suppose'.
 14|. . # O . . . .  . .|14|
 13|. . # . . . . .  . .|13|
 12|. . . . . . . .  . .|12|
 11|. . . . . . . .  . .|11| And here, when there is
 10|. . . + . . . .  . .|10| more of the comment
  9|. . . . . . . .  . .| 9| below, the '+'
  8|. . . . . . . .  . .| 8|+appears to our left.
  7|. . . . . . . .  . .| 7|
  6|. . . . . . . .  . .| 6|   Node #173: Name
  5|. . . . . . . .  . .| 5|-B: variation 1 hit 'B' to see
  4|. . . + . . . .  . .| 4| C: variation 2 hit 'C'
  3|. . . . . . . .  . .| 3| D: variation 3 etc...            
  2|. . . . . . . .  . .| 2| E: variation 4
  1|. . . . . . . .  . .| 1|+F: variation 5
   +---------------  ---+    ? for help    read   long
    A B C D E F G H  S T     
 Black #11 at 'D19'               #: 0      > O: 0 <

The bottom line indicates that Black has just made move #11. On the bottom right, the angle brackets around the white stone indicate that it is White's turn. Above that, the word "read" indicates that the Smart-Go file hasn't been modified, and "long" indicates that the default save format is the long format. "Read" will change to "edit" if you modify the file, and it will say "tutor" if you enter tutor mode.


wrapmgt - prepare short format Smart-Go files for mailing

mailgo - email go game management

mgt2short - script to convert Smart-Go files to short format

RULES - an introduction to the game in Smart-Go format.

The From My Go Teacher tutorial lessons, and many professional game records all available at

Internet go, a program to play go over internet, available on

Smart-Go.def, the Smart-Go format definition.


Comment editing is limited to 120 screen lines.

Most, but not all, of the Smart-Go properties are supported.

Send bug reports to "" or "hale@scam.Berkeley.EDU"


Greg Hale

Jeff Boscole

Adrian Mariano (

Mike Dobbins (