summaryrefslogtreecommitdiff
path: root/referee.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'referee.cpp')
-rw-r--r--referee.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/referee.cpp b/referee.cpp
index d215c3d..08770a7 100644
--- a/referee.cpp
+++ b/referee.cpp
@@ -2,7 +2,6 @@
#include <tuple>
#include <cstdlib>
#include "referee.h"
-#include "params.h"
// Timeout in milliseconds for the feature negotiation at the start of the
// protocol. If the referee hasn't sent anything after this timeout, we assume
@@ -10,14 +9,17 @@
#define FEATURE_TIMEOUT 200
-Referee::Referee(const string_view execname, const vector<string> &players)
- : proc(execname), refereeExecname(execname), numPlayers(players.size()) {
+Referee::Referee(bool verbose, const string_view execname, const vector<string> &players)
+ : verbose(verbose)
+ , proc(execname)
+ , refereeExecname(execname)
+ , numPlayers(players.size()) {
proc.run();
reftag = "REF(" + to_string(proc.getPid()) + ") ";
- if (referee_verbose) {
+ if (verbose) {
cout << reftag << "starting for:";
for (const string &p : players) cout << " " << p;
cout << endl;
@@ -37,7 +39,7 @@ Referee::Referee(const string_view execname, const vector<string> &players)
}
Referee::~Referee() {
- if (referee_verbose) {
+ if (verbose) {
cout << reftag << "stopping" << endl;
}
proc.wait();
@@ -53,7 +55,7 @@ Referee::Event Referee::nextEvent() {
string &command = *ocommand;
- if (referee_verbose) {
+ if (verbose) {
cout << reftag << "read <" << command << ">" << endl;
}
@@ -82,7 +84,7 @@ Referee::Event Referee::nextEvent() {
return ReadEvent{
player,
[this](const string &line) {
- if (referee_verbose) {
+ if (verbose) {
cout << reftag << "write <" << line << ">" << endl;
}
@@ -190,7 +192,7 @@ void Referee::queryFeatures() {
exit(1);
}
- if (referee_verbose) {
+ if (verbose) {
cout << reftag << "read <" << *line << ">" << endl;
}