See the PPCG question for rules and other details.
Call the controller simply with
python controller.py
or pass the number of rounds as an argument (the default is 1):
python controller.py 50
The option -v
can be added to obtain graphical output in ASCII, although it is too large to fit on a screen if too many bots are present.
The option -e
captures the STDERR of all bots and prevents it from being printed.
This may be convenient when writing a bot, if you want to frequently switch between debugging and observing its behavior with -v
.
The option -h
displays a help message.
Scripts/executables for bots should be placed in the subdirectories bots/<botname>
.
When the controller is run, it places an empty text file called data.txt
in each subdirectory.
Each bot can freely access this file during the game.
The controller uses the file bots.txt
to enumerate the bots.
Any line beginning with #
in that file is a comment.
The non-comment lines should occur in triples, with the first one containing the name of a bot, the second its subdirectory, and the third the command to run it.
The commands are executed with the bot's subdirectory as the working directory.
Each bot is executed at the beginning of every round.
The controller writes to the bots' STDIN and reads from their STDOUT.
There are six types of messages that the controller can send, and they are listed in the following.
A letter in brackets, as in [n]
, signifies a variable, as opposed to the actual character n
, and each message and response shall be followed by a newline.
-
BEGIN [B] [T] [S]
is given at the beginning of a round. The numbersB
,T
andS
are the number of bots, the number of turns, and the side length of the grid, respectively. -
DESTROY [T]
is given at the beginning of the destruction phase of turnT
. Your bot shall answer with eitherVERTEX [x],[y]
to break the vertex(x,y)
, orNONE
for no action. Trying to break an active of broken vertex results in your choice being interpreted asNONE
. -
BROKEN [T] [C1] [C2] ... [Cn]
is given at the end of the destruction phase of turnT
. EachCi
is either of the form[x],[y]
, if boti
chose to break the inactive vertex(x,y)
, or the characterN
, if it made no choice. Every bot will receive its own choice asC1
, and the rest in a random order that stays fixed throughout the game. -
ACTIVATE [T]
is given at the beginning of the activation phase of turnT
. It has the same semantics and expected answer format asDESTROY [T]
. -
OWNED [T] [C1] [C2] ... [Cn]
is given at the end of the activation phase of turnT
. It has the same semantics asBROKEN [T] [C1] [C2] ... [Cn]
. -
SCORE [S1] [S2] ... [Sn]
is given after the final turn. Each[Si]
is the score of boti
obtained in this round.
If more than 1 second passes between the initial message/activation report and the next choice of vertex your bot makes, or more than 1 second passes between the score report and the termination of your bot, it is disqualified.