|
@@ -1,12 +1,12 @@
|
|
|
#ifndef CHESSY_MOVEGENERATION_H
|
|
|
-#define CHESSY_MOVEGENERATION_H
|
|
|
+#define CHESSY_MOVEGENERATION_H
|
|
|
|
|
|
#include "BitBoard.h"
|
|
|
|
|
|
namespace chessy
|
|
|
{
|
|
|
struct Move;
|
|
|
-
|
|
|
+
|
|
|
class PositionSet;
|
|
|
|
|
|
class MoveGenerator;
|
|
@@ -17,6 +17,13 @@ struct chessy::Move
|
|
|
{
|
|
|
Index origin;
|
|
|
Index destination;
|
|
|
+
|
|
|
+ Move(void) = default;
|
|
|
+ Move(const Move&) = default;
|
|
|
+ ~Move(void) = default;
|
|
|
+
|
|
|
+ inline Move(Index origin, Index destination) :
|
|
|
+ origin{origin}, destination{destination} {}
|
|
|
};
|
|
|
|
|
|
|
|
@@ -24,6 +31,7 @@ class chessy::PositionSet
|
|
|
{
|
|
|
Bitboard bitboard;
|
|
|
|
|
|
+public:
|
|
|
struct PositionSetIterator
|
|
|
{
|
|
|
Bitboard bitboard;
|
|
@@ -32,11 +40,11 @@ class chessy::PositionSet
|
|
|
{
|
|
|
//if (bitboard == Bitboard(0)) return -1;
|
|
|
return Bitboard::trailingZeroes(bitboard.bits);
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
inline void operator ++(void)
|
|
|
{
|
|
|
- // remove LSB
|
|
|
+ // remove least significant one-bit
|
|
|
bitboard.bits &= bitboard.bits - 1;
|
|
|
}
|
|
|
|
|
@@ -45,15 +53,14 @@ class chessy::PositionSet
|
|
|
return bitboard != psi.bitboard;
|
|
|
}
|
|
|
};
|
|
|
-public:
|
|
|
-
|
|
|
+
|
|
|
inline PositionSetIterator begin(void) const
|
|
|
{
|
|
|
- return PositionSetIterator { bitboard };
|
|
|
+ return PositionSetIterator {bitboard};
|
|
|
}
|
|
|
inline PositionSetIterator end(void) const
|
|
|
{
|
|
|
- return PositionSetIterator { 0 };
|
|
|
+ return PositionSetIterator {0};
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -62,19 +69,21 @@ class chessy::MoveGenerator
|
|
|
{
|
|
|
struct MoveIterator
|
|
|
{
|
|
|
+ PositionSet::PositionSetIterator pawnPushes;
|
|
|
inline Move operator *(void) const
|
|
|
{
|
|
|
- // TODO: implement
|
|
|
+ Index pp = *pawnPushes;
|
|
|
+ return Move(pp - 8, pp);
|
|
|
}
|
|
|
|
|
|
inline void operator ++(void)
|
|
|
{
|
|
|
- // TODO: implement
|
|
|
+ ++pawnPushes;
|
|
|
}
|
|
|
|
|
|
inline bool operator !=(const MoveIterator& psi) const
|
|
|
{
|
|
|
- // TODO: implement
|
|
|
+ pawnPushes != PositionSet::PositionSetIterator {0};
|
|
|
}
|
|
|
};
|
|
|
public:
|