---
name: "xtbot"
section: "6"
platform: "linux"
package: "xtris"
version: "1.15-9"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/xtbot"
---

# xtbot(6)

automatic player for xtris

## NAME

xtbot - automatic player for xtris

## SYNOPSIS

**xtbot** \[ -help \] \[ -n nick \] \[ -quiet \] \[ -test \] \[ *server.name* \[ *port* \] \]

## OPTIONS

- **-help**

  Prints out a summary of the command-line options **xtbot** recognizes.

- **-n**

  Sets the nickname for the bot;  the nickname appears at the bottom of the screen on  **xtris** clients.

- **-quiet**

  Sets quiet mode: **xtbot** will not output any diagnostics or error messages. **xtris** always starts **xtbot** with this option.

- **-test**

  Runs the bot in test mode:  **xtbot** will not connect to a server or show the game in progress, but will just simulate 16 games as fast as it can and print stats on the number of lines it did and the number of bricks it played.

## ARGUMENTS

- **server.name**

  Specifies the machine on which an **xtris** server (**xtserv**) runs. **xtbot** will connect to that server, and add itself to the game.

  If the server is not specified,  **xtbot** will attempt to connect to a server on localhost (127.0.0.1).  If no server is running on localhost, **xtbot** will exit with an error message.

- **port**

  Specifies the port to connect to, if the server was started on a port other than the default (19503).

## DESCRIPTION

**xtbot** is a robot (i.e an automatic player) for  **xtris,** a synchronous multi-user version of Tetris.

**xtbot** connects to an **xtris** server, registers itself as a bot, and simulates a game of Tetris whenever a human player hits 'play'.

The current version of xtbot uses a pretty good decision algorithm, which usually does several thousand lines before losing, when playing on its own.  When playing against a bot, though, the main limiting factor is the speed, whic is why **xtbot** purposefully waits a little before dropping each brick, so that humans can compete speed-wise.

**xtbot** is started automatically by **xtris,** with the option '-quiet', when a player presses the 'bot' button.

Running copies of **xtbot** can be killed either by clicking on their name from an **xtris** window, or by killing the process.

It is fairly easy to adapt **xtbot** to make your own bots based on your favorite decision algorithms. For this the easiest way is to change the decision function in decide.c while keeping the rest of the bot's skeleton (in xtbot.c).  See the comments in decide.c, decide.h and xtbot.h for details about the interface between these.  Alternatively, the protocol between the client and the server is described in detail in the file PROTOCOL, so you can make completely independent bots.

## ENVIRONMENT

The default algorithm for the bot depends on 6 coefficients to evaluate each possible position of the piece.  You can set the environment variables XTBOT\_FRONTIER, XTBOT\_HEIGHT, XTBOT\_HOLE, XTBOT\_DROP, XTBOT\_PIT, XTBOT\_EHOLE.  See the file decide.c to see what they do.

The values for the coefficients that xtbot uses now were obtained with a genetic algorithm using a population of 50 sets of coefficients, calculating 16 generations in about 20 hours on 20-odd Sparc  workstations.  This improved the average number of lines from 10,000 to about 50,000.  The code used for this isn't nearly clean enough to distribute in a release. If you're interesed, please e-mail the author  privately.

## SEE ALSO

[**xtris**(6)](/xtris/6.md), [**xtserv**(6)](/xtserv/6.md)

## BUGS

None known; please report any bugs to the author.

## AUTHOR

**xtbot** was written by Roger Espel Llima \<roger.espel.llima@pobox.com\>.
