summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/main.cpp b/main.cpp
index a4b47ed..ecd12f7 100644
--- a/main.cpp
+++ b/main.cpp
@@ -257,14 +257,26 @@ static void playMatch(Player &p1, Player &p2, int index, const Params &params) {
procs[0].run();
procs[1].run();
+ const auto handleWriteLines = [&referee, &procs]() {
+ for (const auto &p : referee.playerWriteLines()) {
+ assert(0 <= p.first && p.first < 2);
+ procs[p.first].writeLine(p.second);
+ }
+ };
+
+ // Received upon initialisation of referee
+ handleWriteLines();
+
string lastMove = "Start";
while (true) {
for (int i = 0; i < 2; i++) {
- if (!procs[i].writeLine(lastMove)) {
- cout << "ERROR writing move to player " << i+1
- << " (game " << gameCodeName(p1, p2, index) << ")" << endl;
- throw StopCompetitionError();
+ if (!referee.getFeatures().noLastMove) {
+ if (!procs[i].writeLine(lastMove)) {
+ cout << "ERROR writing move to player " << i+1
+ << " (game " << gameCodeName(p1, p2, index) << ")" << endl;
+ throw StopCompetitionError();
+ }
}
procs[i].unStop();
@@ -296,10 +308,7 @@ static void playMatch(Player &p1, Player &p2, int index, const Params &params) {
throw StopCompetitionError();
}
- for (const auto &p : referee.playerWriteLines()) {
- assert(0 <= p.first && p.first < 2);
- procs[p.first].writeLine(p.second);
- }
+ handleWriteLines();
if (referee.gameEnded()) {
mres.status = MatchResult::Status::ok;