summaryrefslogtreecommitdiff
path: root/referee.h
diff options
context:
space:
mode:
Diffstat (limited to 'referee.h')
-rw-r--r--referee.h43
1 files changed, 33 insertions, 10 deletions
diff --git a/referee.h b/referee.h
index 891021d..82b8b02 100644
--- a/referee.h
+++ b/referee.h
@@ -10,16 +10,28 @@
using namespace std;
+struct Features {
+ // If true, players should not receive the last move on stdin.
+ // Used by the match runner.
+ bool noLastMove = false;
+
+ // If true, the referee program can write additional lines to the players.
+ // Used by the Referee class to produce playerWriteLines() output.
+ bool writeLines = false;
+};
+
class Referee {
Process proc;
+ string refereeExecname;
bool isEnd = false;
vector<int> scores;
- bool featureWriteLines = false;
+ Features features;
vector<pair<int, string>> writeLinesList;
- optional<string> readLine();
+ void queryFeatures();
void readScores();
+ void readWriteLines();
public:
Referee(const string_view execname, const vector<string> &players);
@@ -34,13 +46,20 @@ public:
// Kills the referee process
void terminate();
+
+ const Features& getFeatures() const;
};
/*
Referee protocol:
-At startup, the referee receives a line containing the number of players in the
-game, followed by that number of lines containing the players' names.
+At startup, the referee should write a number of lines to stdout of the form
+'feature <name>', indicating that the referee supports the feature given by
+<name>. The list of features should be ended with a line containing
+'feature_end'. For supported features and their effect, see below.
+
+The referee then receives a line containing the number of players in the game,
+followed by that number of lines containing the players' names.
Then, it repeatedly receives a line on stdin of the form '<player> <line>',
where <player> is the index of the player in the game (0 is first, 1 is second,
@@ -53,12 +72,16 @@ then write a line to stdout that is equal to either 'valid', 'invalid', or
the game.
FEATURES
-At any time the referee may write 'feature <name>' to stdout, which enables the
-protocol feature with the given name. The following features are supported:
-- 'write_lines': After a move validity judgement, the referee should write lines
+The following features are supported:
+- 'write_lines': After having received the list of players at the start of the
+ protocol, and after a move validity judgement, the referee should write lines
of the form '<player> <line>' to stdout, where <player> is the index of the
player on whose stdin to write <line>. The referee should signal the end of
- this list by writing a line 'write_end' to stdout.
- This allows the referee to write additional data to players' inputs after they
- have written their moves.
+ this list by writing a line 'write_end' to stdout. This allows the referee to
+ write additional data to players' inputs after they have written their moves.
+ Note that 'valid end' is also a move validity judgement, and the player lines
+ should be written *before* writing the scores.
+- 'no_last_move': Prevent the competition manager from writing the last player's
+ last move to stdin of the next player. Should probably be used in conjunction
+ with 'write_lines'.
*/