1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
//-----------------------------------------------------------------------------
/** @file libpentobi_base/ColorMove.h
@author Markus Enzenberger
@copyright GNU General Public License version 3 or later */
//-----------------------------------------------------------------------------
#ifndef LIBPENTOBI_BASE_COLOR_MOVE_H
#define LIBPENTOBI_BASE_COLOR_MOVE_H
#include "Color.h"
#include "Move.h"
namespace libpentobi_base {
//-----------------------------------------------------------------------------
struct ColorMove
{
Color color;
Move move;
/** Return a color move with a null move and an undefined color.
Even if the color is logically not defined, it is still initialized
(with Color(0)), such that this color move can be used in
comparisons. If you are sure that the color is never used and don't
want to initialize it for efficiency, use the default constructor
and then assign only the move. */
static ColorMove null() { return {Color(0), Move::null()}; }
ColorMove() = default;
ColorMove(Color c, Move mv);
/** Equality operator.
@pre move, color, mv.move, mv.color are initialized. */
bool operator==(ColorMove mv) const;
/** Inequality operator.
@pre move, color, mv.move, mv.color are initialized. */
bool operator!=(ColorMove mv) const { return ! operator==(mv); }
bool is_null() const { return move.is_null(); }
};
inline ColorMove::ColorMove(Color c, Move mv)
: color(c),
move(mv)
{
}
inline bool ColorMove::operator==(ColorMove mv) const
{
return move == mv.move && color == mv.color;
}
//-----------------------------------------------------------------------------
} // namespace libpentobi_base
//-----------------------------------------------------------------------------
#endif // LIBPENTOBI_BASE_COLOR_MOVE_H
|