DOBUTSU(6)

NAME
dobutsu – play Dobutsu Shogi

SYNOPSIS
dobutsu [-qv] [-c color] [-s strength[,strength]] [-t tbfile.tb]

DESCRIPTION
dobutsu is an engine for the Japanese Shogi variant Dobutsu Shogi with a gnuchess(6) like interface. It uses a comprehensive endgame tablebase to achieve perfect play but can also play at any desired strength.

The following options are supported:

-c color
    Make the engine play color. If color is one of bBsS, the engine plays Sente. If it is one of wWgG, the engine plays Gote. More than one colour can be provided to have the engine play against itself.

-q  Do not print the board after each move. This is the default.

-s strength[,strength]
    Set engine strength to strength, a positive floating point number. All values over 700 cause the engine to play perfectly. If two strength values of the form strength,strength are provided, the first strength is used for Sente while the second strength is used for Gote.

-t tbfile.tb
    Load the endgame tablebase from tbfile.tb. If no -t option is provided, the endgame tablebase is loaded from the location indicated in the environment variable DOBUTSU_TABLEBASE. If that variable is unset, the place where the tablebase was installed to and then files dobutsu.tb and dobutsu.tb.xz are tried in the current working directory.

-v  Print the board after each move.

COMMANDS
dobutsu is an interactive program that asks the user for commands and responds to them if requested. All interaction, including error messages, happens on standard input and standard output. Only fatal error messages are printed to standard error. A command is either a move in algebraic notation or one of the following:

both
    Make engine play both players, immediately playing out the rest of the game at current engine strengths.

exit
    Exit the program.

force
    Set the engine to play neither Sente nor Gote.

go  Make the engine play the colour that is currently on the move.

help
    Print a list of commands.

hint
    Print what the engine would play.

new [position]
    Start a new game. If position is provided, use the specified position as the starting position, otherwise use the default position. The format of the position string is adopted from Forsyth-Edwards-Notation. Refer to the output of show position for how this notation works.

remove
    Undo the last two moves.

setup [position]
    Alias for new.

show thing
    Print various useful pieces of information. Valid values for thing are:

    board
        Print the current board.

    setup
        Print board as a position string

    moves
        Print possible moves.

    eval
        Print position evaluation.

    lines
        Print possible moves and their evaluation.

strength [strength [strength]]
    If invoked with no arguments, print the current engine strengths.

    If invoked with one or two arguments, set engine strength to a positive floating-point number. If two strengths are provided, the first one is used for Sente while the second one is used for Gote. A strength above 700 makes the engine play perfectly.

undo
    Undo the previous move. If the last move was an engine move, the engine is going to play another move immediately. Either use force to stop the engine or remove to undo two moves at a time.

quiet
    Do not print the board after every move.

quit
    Quit the program.

verbose
    Print the board after every move.

version
    Print program version.

RULES
Dobutsu Shogi is a two-player strategy game played on a 3×4 board. Each player has four pieces: A lion, an elephant, a giraffe, and a chick. The player whose lion starts on the fourth rank is called Sente. His pieces are denoted by uppercase characters. The other player is called Gote, denoted by lowercase characters. Sente makes the first move, then both players alternate moves. The initial setup looks like this:

      ABC
     +---+
    1|gle|
    2| c |
    3| C |
    4|ELG|
     +---+

The goal of the game is to either capture the opponents lion, or to advance one's own lion to an unattacked square in the promotion zone, which is the rank farthest from the lion's starting square. Sente's promotion zone is rank 1, whereas Gote's promotion zone is rank 4.

Each piece can move in a variety of ways: The lion can move one square into every direction, the elephant can move one square diagonally, the giraffe can move one square horizontally or vertically, the chick can move one square towards the promotion zone. When a chick is moved into the promotion zone, it is promoted to a rooster, which can move horizontally, vertically, or diagonally towards the promotion zone. The following diagram shows with asterisks the squares each of Sente's pieces can move to:

    ***  * *   *    *   ***
    *L*   E   *G*   C   *R*
    ***  * *   *         *

Pieces cannot move onto squares occupied by a player's own pieces. When a piece is moved onto a square occupied by an opponent's piece, that piece is captured and transferred into the hand of the capturer. If the captured piece is a rooster, it is unpromoted to a chick. Instead of moving a piece, a player may also drop one of the piece in his hand onto an arbitrary square on the board.

If a board position is repeated for the third time, the game is a draw. There is no stalemate; if the only possible move is to move into check, the lion has to move into check. If no move is possible, the side to move looses the game.

ENVIRONMENT

DOBUTSU_TABLEBASE
    Endgame tablebase location.

FILES

dobutsu.tb, dobutsu.tb.xz
    Endgame tablebase files.

EXIT STATUS

1   A fatal error occured.

0   No fatal error occured.

EXAMPLES
The following is a sample session with some commands demonstrated. The program prints the current move number as a prompt, user input is printed in bold.

    Loading tablebase... done
    1. show board
      ABC
     +---+
    1|gle|
    2| c |
    3| C |
    4|ELG| *
     +---+
    1. Cb3b2
    2. show board
      ABC
     +---+
    1|gle| *
    2| C |
    3|   |
    4|ELG| C
     +---+
    2. show setup
    G/gle/-C-/---/ELG/C
    2. show lines
    Ec1xb2 : #75   (24.22%)
    Lb1xb2 : #-72  (22.95%)
    Lb1-c2 : #-30  (22.07%)
    Lb1-a2 : #-30  (22.07%)
    Ga1-a2 : #-2   ( 8.68%)
    2. strength 20
    2. show lines
    Ec1xb2 : #75   (60.59%)
    Lb1xb2 : #-72  (20.54%)
    Lb1-c2 : #-30  ( 9.44%)
    Lb1-a2 : #-30  ( 9.44%)
    Ga1-a2 : #-2   ( 0.00%)
    2. show moves
    Ga1-a2
    Ec1xb2
    Lb1-c2
    Lb1xb2
    Lb1-a2
    2. show eval
    #75
    2. go
    My 2. move is : Ec1xb2
    3. go
    My 3. move is : Gc4-c3
    4. show setup
    G/gl-/-e-/-C-/ELG/c
    4. quit

DIAGNOSTICS

Loading tablebase... tbfile.tb: some error
    The tablebase could not be loaded for some reason. All functionality that accesses the tablebase is unavailable.

Error (tablebase unavailable) : some command
    The tablebase could not be loaded and you tried to execute a command that requires the tablebase to be loaded.

Error (invalid position) : some command
    You entered a new or setup command with an invalid position string.

Error (unknown command) : some command
    You entered a command that is not known to this program. Type help for a list of commands.

Error (strength must be positive) : some command
    You tried to set the engine strength to a nonpositive value.

Error (invalid strength) : some command
    You used the strength command with an argument that could not be parsed into a floating point number.

SEE ALSO
gnuchess(6), gnugo(6), xboard(6)

CAVEATS
Even though its user interface is very similar to gnuchess(6), dobutsu(6) is not xboard(6) compatible.

Stricly speaking, the Dobutsu Shogi rules allow either play to move his Lion to an attacked square on the fourth rank without winning. The lion can then immediately be captured by the opponent. As the rules are not clear as to what happens when the opponent does not immediately capture, this implementation does not allow the lion to move onto an attacked square on the fourth rank. Moving into check is allowed in other situations.

The -s strength option adjusts a weighting function used during move selection. As the only information the engine has about the position's evaluation is the entry in the endgame tablebase, its notion of what is a good move sometimes differs from what a human thinks.

HISTORY
Dobutsu Shogi is a Shogi variant invented by professional Shogi player Madoka Kitao in 2008 and solved by University of Tokyo researcher Tanaka Tetsuro in 2009. Development of this software began as a hobby project in July 2016 and concluded in February 2017.

AUTHOR
Robert Clausecker <fuz@fuz.su>