Skip to content

How to create an old referee

dreignier edited this page Mar 16, 2018 · 2 revisions

Warning

This page explain how to create an old referee for cg-brutaltester. Old games are all games created before Botters of the Galaxy and Ultimate Tic Tac Toe.

If you want to use and old referee with cg-brutaltester, you have to use the -o flag. See the documentation for more details.

Introduction

Your referee must be runnable with a command line (or you won't be able to give it to cg-brutaltester) and you have to use the standard input and output streams. The referee can output on the error stream for debug purposes or real errors. It will be stored in the log file of the game. cg-brutaltester is a very naive arena, and the referee must tell it how to work.

Setting a seed (optional)

If you want to swap player positions (useful on asymmetric maps), read the line ###Seed N, with N >= 0. This line will be passed even before ###Start, if the -s flag is set for starting the brutaltester. When getting the same seed, your referee has to create the same map.

Start of a game

The first line received by the referee will be ###Start N. Where N is the number of players for this game.

Send inputs for a player

If the referee wants to give inputs for a player, it must first output ###Input X\n where X is the index of the player (player 1 is 0). Don't forget the \n. After this line, every output of the referee will be forwarded to the process of the player X.

Asking for outputs of a player

If the referee wants to receive outputs from a player, it must output ###Output X N\n. X is the index of the player (player 1 is 0). N is the number of lines. Don't forget the \n. If you want 5 lines of outputs from player 3, just output ###Output 2 5\n.

End of the game

To stop the game, the referee must output ###End <results>\n. Don't forget the \n. The results contain the position of each player separated by a space. If some players end at the same position, just put those players' indexes in the same position. Some examples:

  • ###End 0 2 3 1 : Player 1 is the winner. Player 3 is the second. Player 4 is the third. Player 2 is the fourth.
  • ###End 1 0 : Player 2 is the winner. Player 1 is the second.
  • ###End 01 : It's a draw between players 1 and 2.
  • ###End 1 03 2 : Player 2 is the winner. Player 1 and 4 are both at the second place. Player 3 is the third.
  • ###End 02 31 : Players 1 and 3 are both at the first place. Players 4 and 2 are both at the second place.