From 819a1064c5142a9b2f04ff8149d34fc915c18322 Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Fri, 8 Jun 2018 10:31:22 +0100 Subject: Refactor legal moves gen and moves logic --- src/main/game/move.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/game/move.cpp (limited to 'src/main/game/move.cpp') diff --git a/src/main/game/move.cpp b/src/main/game/move.cpp new file mode 100644 index 0000000..053b3ba --- /dev/null +++ b/src/main/game/move.cpp @@ -0,0 +1,22 @@ +// +// Created by thecharlesblake on 07/06/18. +// + +#include "move.h" + +const pile::size_type move::dominance_flag = pile::max_size_type; + +move::move(pile::ref f, pile::ref t, pile::size_type i) : from(f), to(t), count(i) { + assert(i >= 1); +} + +// Returns true is the move has been flagged as a special 'dominance' move +bool move::is_dominance() const { + return count == dominance_flag; +} + +bool operator==(const move& a, const move& b) { + return (a.from == b.from ) + && (a.to == b.to ) + && (a.count == b.count); +} \ No newline at end of file -- cgit v1.2.1 From a7396c5497601855fad019cfd145ca6c93e1c40f Mon Sep 17 00:00:00 2001 From: Charlie Blake Date: Fri, 8 Jun 2018 21:54:48 +0100 Subject: Refactor moves logic --- src/main/game/move.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/main/game/move.cpp') diff --git a/src/main/game/move.cpp b/src/main/game/move.cpp index 053b3ba..ff8269c 100644 --- a/src/main/game/move.cpp +++ b/src/main/game/move.cpp @@ -4,19 +4,16 @@ #include "move.h" -const pile::size_type move::dominance_flag = pile::max_size_type; - -move::move(pile::ref f, pile::ref t, pile::size_type i) : from(f), to(t), count(i) { - assert(i >= 1); -} - -// Returns true is the move has been flagged as a special 'dominance' move -bool move::is_dominance() const { - return count == dominance_flag; +move::move(mtype ty, pile::ref f, pile::ref t, pile::size_type i) : type(ty), from(f), to(t), count(i) { +#ifndef NDEBUG + if (ty == mtype::regular) assert(i == 1); + else assert(i >= 1); +#endif } bool operator==(const move& a, const move& b) { - return (a.from == b.from ) + return (a.from == b.from ) && (a.to == b.to ) - && (a.count == b.count); -} \ No newline at end of file + && (a.count == b.count) + && (a.type == b.type ); +} -- cgit v1.2.1