if ( ((ss >> col) && (col >= 'a' && col <= 'h'))
&& ((ss >> row) && (row == '3' || row == '6')))
{
- st->epSquare = make_square(file_from_char(col), rank_from_char(row));
+ st->epSquare = make_square(File(col - 'a') + FILE_A, Rank(row - '1') + RANK_1);
// Ignore if no capture is possible
Color them = opposite_color(sideToMove);
if (failedStep) *failedStep = 1;
// Side to move OK?
- if (!color_is_ok(side_to_move()))
+ if (side_to_move() != WHITE && side_to_move() != BLACK)
return false;
// Are the king squares in the position correct?
// Castle files OK?
if (failedStep) (*failedStep)++;
- if (!file_is_ok(initialKRFile))
+ if (!square_is_ok(make_square(initialKRFile, RANK_1)))
return false;
- if (!file_is_ok(initialQRFile))
+ if (!square_is_ok(make_square(initialQRFile, RANK_1)))
return false;
// Do both sides have exactly one king?
return Color(c ^ 1);
}
-inline bool color_is_ok(Color c) {
- return c == WHITE || c == BLACK;
-}
-
-inline bool piece_type_is_ok(PieceType pt) {
- return pt >= PAWN && pt <= KING;
-}
-
-inline bool piece_is_ok(Piece p) {
- return piece_type_is_ok(type_of_piece(p)) && color_is_ok(color_of_piece(p));
-}
-
inline char piece_type_to_char(PieceType pt) {
static const char ch[] = " PNBRQK";
return ch[pt];
return Square((r << 3) | f);
}
+inline bool square_is_ok(Square s) {
+ return s >= SQ_A1 && s <= SQ_H8;
+}
+
inline File square_file(Square s) {
return File(s & 7);
}
return Max(file_distance(s1, s2), rank_distance(s1, s2));
}
-inline File file_from_char(char c) {
- return File(c - 'a') + FILE_A;
-}
-
inline char file_to_char(File f) {
return char(f - FILE_A + int('a'));
}
-inline Rank rank_from_char(char c) {
- return Rank(c - '1') + RANK_1;
-}
-
inline char rank_to_char(Rank r) {
return char(r - RANK_1 + int('1'));
}
return std::string(ch);
}
-inline bool file_is_ok(File f) {
- return f >= FILE_A && f <= FILE_H;
-}
-
-inline bool rank_is_ok(Rank r) {
- return r >= RANK_1 && r <= RANK_8;
-}
-
-inline bool square_is_ok(Square s) {
- return s >= SQ_A1 && s <= SQ_H8;
-}
-
inline Square pawn_push(Color c) {
return c == WHITE ? DELTA_N : DELTA_S;
}