Old Jhex file format

(This is the OLD format.  Newly saved files will be in the new format.)

[Game file] =       [key-val list] [(root) node]
                    (Global game parameters (board size, etc.), followed
                    by the game tree.)

[key-val list] =    [key-val pair] [key-val pair] ... [zero-byte]
                    (A list of key-value pairs.  List terminated by a zero byte.)

[key-val pair] =     [1 unsigned byte giving length of key string]
                    [key string (NOT zero-terminated)]
                    [4 byte integer in "network" order giving length of value]
                    [the value]
                    (Examples: 'size' => 10 would be encoded as the bytes
                    {\x04 's' 'i' 'z' 'e' \x00 \x00 \x00 \x01 \x0a}.
                    'vplayer' => 'vvvjv' would be {\x06 'v' 'p' 'l' 'a' 'y' 'e' 'r'
                    \x00 \x00 \x00 \x05 'v' 'v' 'v' 'j' 'v'}.  The format of the
                    value depends on the key.)

(Note: The format of the value depends on the key.  Currently in use are:

    'size' - 1 byte unsigned integer; the size of the hex board; required
    'vplayer' - string; name of vertical player; optional
    'hplayer' - string; name of horizontal player; optional
    'name' - string; name of game; optional
)

[node] =            [key-val list] [number of child nodes (4 byte network integer)] 
                    [child node 1] [child node 2] ...

For a node the keys are:

    'm' - 3 bytes (see below for format); the move (e.g. player 1 plays at (3,4));
            required, except at root node
    'v' - 4 byte float (this will change in the future); current convention
            is that 1 means player 1 wins, -1 means that player 2 wins; optional
    'g' - 1 byte integer/boolean; true means that this is the move that was played
            in the actual game; optional
    'c' - string, 4 byte length then the string itself without terminating 0 byte;
            the comment associated to this node; optional

Format of 3 byte move: [1 byte x coordinate] [1 byte y coordinate] [1 byte player number].
x and y coordinates are in the range 0 ... board_size-1.  Player number is 1 (first 
player) or 2 (second player)