summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2019-02-15 23:34:26 +0100
committertomsmeding <tom.smeding@gmail.com>2019-02-15 23:34:43 +0100
commitda16f39035e21603551360aaca10899e32f0f2e4 (patch)
treef0fc03f584127ec94fdce1985317441e48b88e4b
parent5c3415af4a2881b3ca7cdb4ef5bbf240b4a8b93b (diff)
Correctly print "TIE"
-rw-r--r--TODO.txt1
-rw-r--r--main.cpp15
2 files changed, 9 insertions, 7 deletions
diff --git a/TODO.txt b/TODO.txt
deleted file mode 100644
index 2896735..0000000
--- a/TODO.txt
+++ /dev/null
@@ -1 +0,0 @@
-competition now has feature write_lines, so a referee for this game can be implemented.
diff --git a/main.cpp b/main.cpp
index 4282c47..d0934f4 100644
--- a/main.cpp
+++ b/main.cpp
@@ -30,6 +30,8 @@ int main() {
cout << bd << endl;
+ uint8_t win = 0;
+
uint8_t onturn = 1;
while (bd.bag.totalLeft() > 0) {
cout << "--- NEXT TURN: " << Stone(onturn) << " ---" << endl;
@@ -44,17 +46,18 @@ int main() {
}
uint8_t clr = bd.bag.drawRandom();
- uint8_t win = bd.putCW(idx, clr);
+ win = bd.putCW(idx, clr);
cout << bd << endl;
- if (win != 0) {
- cout << "Winner: " << Stone(clr) << endl;
- break;
- }
+ if (win != 0) break;
onturn = NEXTTURN(onturn);
}
- cout << "TIE" << endl;
+ if (win == 0) {
+ cout << "TIE" << endl;
+ } else {
+ cout << "Winner: " << Stone(win) << endl;
+ }
}