X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Ftypes.h;h=1def7d00aeb8f200230c7b50911e71c2acfdeb91;hp=eea31e3b6f229cf8cc72b1abcdb8c363fce88216;hb=293c44bc09587259818a82e1d2afb511e552badd;hpb=96d3b1c92b8db7d2238fc4993a4f3da49f04d614 diff --git a/src/types.h b/src/types.h index eea31e3b..1def7d00 100644 --- a/src/types.h +++ b/src/types.h @@ -1,7 +1,7 @@ /* Stockfish, a UCI chess playing engine derived from Glaurung 2.1 Copyright (C) 2004-2008 Tord Romstad (Glaurung author) - Copyright (C) 2008-2012 Marco Costalba, Joona Kiiski, Tord Romstad + Copyright (C) 2008-2013 Marco Costalba, Joona Kiiski, Tord Romstad Stockfish is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ /// | only in 64-bit mode. For compiling requires hardware with /// | popcnt support. +#include #include #include #include @@ -130,12 +131,6 @@ enum MoveType { CASTLE = 3 << 14 }; -enum CheckType { - NO_CHECK, - DIRECT_CHECK, - DISCO_CHECK -}; - enum CastleRight { // Defined as in PolyGlot book hash key CASTLES_NONE = 0, WHITE_OO = 1, @@ -397,7 +392,8 @@ inline PieceType type_of(Piece p) { } 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) { @@ -445,8 +441,8 @@ inline int square_distance(Square s1, Square s2) { 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) { @@ -479,7 +475,7 @@ inline Move make_move(Square from, Square to) { template 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) { @@ -493,21 +489,4 @@ inline const std::string square_to_string(Square s) { return ch; } -/// Our insertion sort implementation, works with pointers and iterators and is -/// guaranteed to be stable, as is needed. -template -void sort(K begin, K end) -{ - T tmp; - K p, q; - - for (p = begin + 1; p < end; p++) - { - tmp = *p; - for (q = p; q != begin && *(q-1) < tmp; --q) - *q = *(q-1); - *q = tmp; - } -} - #endif // !defined(TYPES_H_INCLUDED)