diff --git a/main.cpp b/main.cpp index 28d5b3a..712b5f0 100644 --- a/main.cpp +++ b/main.cpp @@ -121,13 +121,18 @@ Moves serialize(const string &s) { throw invalid_argument(err); } - result.x <<= 1; - result.y <<= 1; + result.x = (result.x << 1) - 1; + result.y = (result.y << 1) - 1; string player; int x, y; while (iss >> player >> x >> y) { if (player == "END") break; + if (x >= result.x || y >= result.y) { + string err = "Invalid move by: " + player + " (" + toString(x) + ", " + toString(y) + ")"; + throw invalid_argument(err); + } + if (!isValidPlayer(player[0])) { string err = "Invalid player: " + player; throw invalid_argument(err);