/// | only in 64-bit mode. For compiling requires hardware with
/// | popcnt support.
+#include <cassert>
#include <cctype>
#include <climits>
#include <cstdlib>
}
inline Color color_of(Piece p) {
- return p == NO_PIECE ? NO_COLOR : Color(p >> 3);
+ assert(p != NO_PIECE);
+ return Color(p >> 3);
}
inline bool is_ok(Square s) {
return SquareDistance[s1][s2];
}
-inline char file_to_char(File f) {
- return char(f - FILE_A + 'a');
+inline char file_to_char(File f, bool tolower = true) {
+ return char(f - FILE_A + (tolower ? 'a' : 'A'));
}
inline char rank_to_char(Rank r) {
template<MoveType T>
inline Move make(Square from, Square to, PieceType pt = KNIGHT) {
- return Move(to | (from << 6) | T | ((pt - KNIGHT) << 12)) ;
+ return Move(to | (from << 6) | T | ((pt - KNIGHT) << 12));
}
inline bool is_ok(Move m) {
/// Our insertion sort implementation, works with pointers and iterators and is
/// guaranteed to be stable, as is needed.
template<typename T, typename K>
-void sort(K first, K last)
+void sort(K begin, K end)
{
T tmp;
K p, q;
- for (p = first + 1; p < last; p++)
+ for (p = begin + 1; p < end; p++)
{
tmp = *p;
- for (q = p; q != first && *(q-1) < tmp; --q)
+ for (q = p; q != begin && *(q-1) < tmp; --q)
*q = *(q-1);
*q = tmp;
}