From da16f39035e21603551360aaca10899e32f0f2e4 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Fri, 15 Feb 2019 23:34:26 +0100 Subject: Correctly print "TIE" --- TODO.txt | 1 - main.cpp | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) delete mode 100644 TODO.txt 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; + } } -- cgit v1.2.3-54-g00ecf