(Some positions are from http://www.chessbox.de/Compu/schachzahl4_e.html)
Code: Select all
ui64 Pos::SimpleEMP(const ui depth)
{
ui64 count;
if (depth == 0) count = 1;
else
{
if (depth == 1) count = CountMoves();
else
{
GMVec gmvec(*this);
count = 0;
for (ui i = 0; i < gmvec.GetCount(); i++)
{
Execute(gmvec[i]); count += SimpleEMP(depth - 1); Retract();
};
};
};
return count;
}
bool TensorTask::SelfTestMPGAux(
const char *fenstr, const ui64 c1, const ui64 c2, const ui64 c3, const ui64 c4) const
{
bool pass;
Pos pos;
if (!pos.LoadFromString(fenstr)) pass = false;
else
pass =
(pos.SimpleEMP(1) == c1) && (pos.SimpleEMP(2) == c2) &&
(pos.SimpleEMP(3) == c3) && (pos.SimpleEMP(4) == c4);
if (!pass) std::clog << "Tensor::SelfTestMPGAux: Failed position: " << fenstr << '\n';
return pass;
}
bool TensorTask::SelfTestMPG(void) const
{
bool pass = true;
if (pass) pass = SelfTestMPGAux("2qrr1n1/3b1kp1/2pBpn1p/1p2PP2/p2P4/1BP5/P3Q1PP/4RRK1 w - - 0 1", 44, 833, 35770, 766147);
if (pass) pass = SelfTestMPGAux("8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1", 14, 191, 2812, 43238);
if (pass) pass = SelfTestMPGAux("8/3K4/2p5/p2b2r1/5k2/8/8/1q6 b - - 0 1", 50, 279, 13310, 54703);
if (pass) pass = SelfTestMPGAux("8/7p/p5pb/4k3/P1pPn3/8/P5PP/1rB2RK1 b - d3 0 1", 5, 117, 3293, 67197);
if (pass) pass = SelfTestMPGAux("8/PPP4k/8/8/8/8/4Kppp/8 w - - 0 1", 18, 290, 5044, 89363);
if (pass) pass = SelfTestMPGAux("r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1", 48, 2039, 97862, 4085603);
if (pass) pass = SelfTestMPGAux("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", 20, 400, 8902, 197281);
return pass;
}