Position& Position::set(const string& code, Color c, StateInfo* si) {
- assert(code.length() > 0 && code.length() < 8);
assert(code[0] == 'K');
string sides[] = { code.substr(code.find('K', 1)), // Weak
- code.substr(0, code.find('K', 1)) }; // Strong
+ code.substr(0, std::min(code.find('v'), code.find('K', 1))) }; // Strong
+
+ assert(sides[0].length() > 0 && sides[0].length() < 8);
+ assert(sides[1].length() > 0 && sides[1].length() < 8);
std::transform(sides[c].begin(), sides[c].end(), sides[c].begin(), tolower);
case CASTLING:
{
Square kfrom = from;
- Square rfrom = to; // Castling is encoded as 'King captures the rook'
+ Square rfrom = to; // Castling is encoded as 'king captures the rook'
Square kto = relative_square(sideToMove, rfrom > kfrom ? SQ_G1 : SQ_C1);
Square rto = relative_square(sideToMove, rfrom > kfrom ? SQ_F1 : SQ_D1);
// Return a draw score if a position repeats once earlier but strictly
// after the root, or repeats twice before or at the root.
- if (st->repetition && st->repetition < ply)
- return true;
-
- return false;
+ return st->repetition && st->repetition < ply;
}