summaryrefslogtreecommitdiff
path: root/move.cpp
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2018-03-12 00:20:50 +0100
committertomsmeding <tom.smeding@gmail.com>2018-03-12 00:20:50 +0100
commitb26b8840e2cebec9ea8294d24ceb6663942005d4 (patch)
tree295d74c04bc9b6496e5a06a76234d87e876b3fe9 /move.cpp
Initial
Diffstat (limited to 'move.cpp')
-rw-r--r--move.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/move.cpp b/move.cpp
new file mode 100644
index 0000000..70c7610
--- /dev/null
+++ b/move.cpp
@@ -0,0 +1,21 @@
+#include <cassert>
+#include "move.h"
+
+
+Move::Move(const char *str) {
+ if (str[0] >= 'a' && str[0] <= 'h' &&
+ str[1] >= '1' && str[1] <= '8' &&
+ str[2] >= 'a' && str[2] <= 'h' &&
+ str[3] >= '1' && str[3] <= '8' &&
+ str[4] == '\0') {
+ from = 8 * ('8' - str[1]) + str[0] - 'a';
+ to = 8 * ('8' - str[3]) + str[2] - 'a';
+ castle = 0;
+ } else if (strcmp(str, "O-O") == 0) {
+ castle = 1;
+ } else if (strcmp(str, "O-O-O") == 0) {
+ castle = -1;
+ } else {
+ throw std::runtime_error("Invalid Move string");
+ }
+}