mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Big headers cleanup
No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
feb5342b39
commit
74160ac602
17 changed files with 105 additions and 186 deletions
|
@ -38,64 +38,6 @@
|
||||||
#include "direction.h"
|
#include "direction.h"
|
||||||
|
|
||||||
|
|
||||||
////
|
|
||||||
//// Constants and variables
|
|
||||||
////
|
|
||||||
|
|
||||||
const Bitboard SquaresByColorBB[2] = {BlackSquaresBB, WhiteSquaresBB};
|
|
||||||
|
|
||||||
const Bitboard FileBB[8] = {
|
|
||||||
FileABB, FileBBB, FileCBB, FileDBB, FileEBB, FileFBB, FileGBB, FileHBB
|
|
||||||
};
|
|
||||||
|
|
||||||
const Bitboard NeighboringFilesBB[8] = {
|
|
||||||
FileBBB, FileABB|FileCBB, FileBBB|FileDBB, FileCBB|FileEBB,
|
|
||||||
FileDBB|FileFBB, FileEBB|FileGBB, FileFBB|FileHBB, FileGBB
|
|
||||||
};
|
|
||||||
|
|
||||||
const Bitboard ThisAndNeighboringFilesBB[8] = {
|
|
||||||
FileABB|FileBBB, FileABB|FileBBB|FileCBB,
|
|
||||||
FileBBB|FileCBB|FileDBB, FileCBB|FileDBB|FileEBB,
|
|
||||||
FileDBB|FileEBB|FileFBB, FileEBB|FileFBB|FileGBB,
|
|
||||||
FileFBB|FileGBB|FileHBB, FileGBB|FileHBB
|
|
||||||
};
|
|
||||||
|
|
||||||
const Bitboard RankBB[8] = {
|
|
||||||
Rank1BB, Rank2BB, Rank3BB, Rank4BB, Rank5BB, Rank6BB, Rank7BB, Rank8BB
|
|
||||||
};
|
|
||||||
|
|
||||||
const Bitboard RelativeRankBB[2][8] = {
|
|
||||||
{
|
|
||||||
Rank1BB, Rank2BB, Rank3BB, Rank4BB, Rank5BB, Rank6BB, Rank7BB, Rank8BB
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Rank8BB, Rank7BB, Rank6BB, Rank5BB, Rank4BB, Rank3BB, Rank2BB, Rank1BB
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const Bitboard InFrontBB[2][8] = {
|
|
||||||
{
|
|
||||||
Rank2BB | Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
|
|
||||||
Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
|
|
||||||
Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
|
|
||||||
Rank5BB | Rank6BB | Rank7BB | Rank8BB,
|
|
||||||
Rank6BB | Rank7BB | Rank8BB,
|
|
||||||
Rank7BB | Rank8BB,
|
|
||||||
Rank8BB,
|
|
||||||
EmptyBoardBB
|
|
||||||
},
|
|
||||||
{
|
|
||||||
EmptyBoardBB,
|
|
||||||
Rank1BB,
|
|
||||||
Rank2BB | Rank1BB,
|
|
||||||
Rank3BB | Rank2BB | Rank1BB,
|
|
||||||
Rank4BB | Rank3BB | Rank2BB | Rank1BB,
|
|
||||||
Rank5BB | Rank4BB | Rank3BB | Rank2BB | Rank1BB,
|
|
||||||
Rank6BB | Rank5BB | Rank4BB | Rank3BB | Rank2BB | Rank1BB,
|
|
||||||
Rank7BB | Rank6BB | Rank5BB | Rank4BB | Rank3BB | Rank2BB | Rank1BB
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined(USE_COMPACT_ROOK_ATTACKS)
|
#if defined(USE_COMPACT_ROOK_ATTACKS)
|
||||||
|
|
||||||
Bitboard RankAttacks[8][64], FileAttacks[8][64];
|
Bitboard RankAttacks[8][64], FileAttacks[8][64];
|
||||||
|
@ -270,6 +212,7 @@ Bitboard QueenPseudoAttacks[64];
|
||||||
////
|
////
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void init_masks();
|
void init_masks();
|
||||||
void init_ray_bitboards();
|
void init_ray_bitboards();
|
||||||
void init_attacks();
|
void init_attacks();
|
||||||
|
|
|
@ -84,8 +84,7 @@ const Bitboard EmptyBoardBB = 0ULL;
|
||||||
|
|
||||||
const Bitboard WhiteSquaresBB = 0x55AA55AA55AA55AAULL;
|
const Bitboard WhiteSquaresBB = 0x55AA55AA55AA55AAULL;
|
||||||
const Bitboard BlackSquaresBB = 0xAA55AA55AA55AA55ULL;
|
const Bitboard BlackSquaresBB = 0xAA55AA55AA55AA55ULL;
|
||||||
|
const Bitboard SquaresByColorBB[2] = { BlackSquaresBB, WhiteSquaresBB };
|
||||||
extern const Bitboard SquaresByColorBB[2];
|
|
||||||
|
|
||||||
const Bitboard FileABB = 0x0101010101010101ULL;
|
const Bitboard FileABB = 0x0101010101010101ULL;
|
||||||
const Bitboard FileBBB = 0x0202020202020202ULL;
|
const Bitboard FileBBB = 0x0202020202020202ULL;
|
||||||
|
@ -96,9 +95,21 @@ const Bitboard FileFBB = 0x2020202020202020ULL;
|
||||||
const Bitboard FileGBB = 0x4040404040404040ULL;
|
const Bitboard FileGBB = 0x4040404040404040ULL;
|
||||||
const Bitboard FileHBB = 0x8080808080808080ULL;
|
const Bitboard FileHBB = 0x8080808080808080ULL;
|
||||||
|
|
||||||
extern const Bitboard FileBB[8];
|
const Bitboard FileBB[8] = {
|
||||||
extern const Bitboard NeighboringFilesBB[8];
|
FileABB, FileBBB, FileCBB, FileDBB, FileEBB, FileFBB, FileGBB, FileHBB
|
||||||
extern const Bitboard ThisAndNeighboringFilesBB[8];
|
};
|
||||||
|
|
||||||
|
const Bitboard NeighboringFilesBB[8] = {
|
||||||
|
FileBBB, FileABB|FileCBB, FileBBB|FileDBB, FileCBB|FileEBB,
|
||||||
|
FileDBB|FileFBB, FileEBB|FileGBB, FileFBB|FileHBB, FileGBB
|
||||||
|
};
|
||||||
|
|
||||||
|
const Bitboard ThisAndNeighboringFilesBB[8] = {
|
||||||
|
FileABB|FileBBB, FileABB|FileBBB|FileCBB,
|
||||||
|
FileBBB|FileCBB|FileDBB, FileCBB|FileDBB|FileEBB,
|
||||||
|
FileDBB|FileEBB|FileFBB, FileEBB|FileFBB|FileGBB,
|
||||||
|
FileFBB|FileGBB|FileHBB, FileGBB|FileHBB
|
||||||
|
};
|
||||||
|
|
||||||
const Bitboard Rank1BB = 0xFFULL;
|
const Bitboard Rank1BB = 0xFFULL;
|
||||||
const Bitboard Rank2BB = 0xFF00ULL;
|
const Bitboard Rank2BB = 0xFF00ULL;
|
||||||
|
@ -109,9 +120,35 @@ const Bitboard Rank6BB = 0xFF0000000000ULL;
|
||||||
const Bitboard Rank7BB = 0xFF000000000000ULL;
|
const Bitboard Rank7BB = 0xFF000000000000ULL;
|
||||||
const Bitboard Rank8BB = 0xFF00000000000000ULL;
|
const Bitboard Rank8BB = 0xFF00000000000000ULL;
|
||||||
|
|
||||||
extern const Bitboard RankBB[8];
|
const Bitboard RankBB[8] = {
|
||||||
extern const Bitboard RelativeRankBB[2][8];
|
Rank1BB, Rank2BB, Rank3BB, Rank4BB, Rank5BB, Rank6BB, Rank7BB, Rank8BB
|
||||||
extern const Bitboard InFrontBB[2][8];
|
};
|
||||||
|
|
||||||
|
const Bitboard RelativeRankBB[2][8] = {
|
||||||
|
{ Rank1BB, Rank2BB, Rank3BB, Rank4BB, Rank5BB, Rank6BB, Rank7BB, Rank8BB },
|
||||||
|
{ Rank8BB, Rank7BB, Rank6BB, Rank5BB, Rank4BB, Rank3BB, Rank2BB, Rank1BB }
|
||||||
|
};
|
||||||
|
|
||||||
|
const Bitboard InFrontBB[2][8] = {
|
||||||
|
{ Rank2BB | Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
|
||||||
|
Rank3BB | Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
|
||||||
|
Rank4BB | Rank5BB | Rank6BB | Rank7BB | Rank8BB,
|
||||||
|
Rank5BB | Rank6BB | Rank7BB | Rank8BB,
|
||||||
|
Rank6BB | Rank7BB | Rank8BB,
|
||||||
|
Rank7BB | Rank8BB,
|
||||||
|
Rank8BB,
|
||||||
|
EmptyBoardBB
|
||||||
|
},
|
||||||
|
{ EmptyBoardBB,
|
||||||
|
Rank1BB,
|
||||||
|
Rank2BB | Rank1BB,
|
||||||
|
Rank3BB | Rank2BB | Rank1BB,
|
||||||
|
Rank4BB | Rank3BB | Rank2BB | Rank1BB,
|
||||||
|
Rank5BB | Rank4BB | Rank3BB | Rank2BB | Rank1BB,
|
||||||
|
Rank6BB | Rank5BB | Rank4BB | Rank3BB | Rank2BB | Rank1BB,
|
||||||
|
Rank7BB | Rank6BB | Rank5BB | Rank4BB | Rank3BB | Rank2BB | Rank1BB
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
extern Bitboard SetMaskBB[65];
|
extern Bitboard SetMaskBB[65];
|
||||||
extern Bitboard ClearMaskBB[65];
|
extern Bitboard ClearMaskBB[65];
|
||||||
|
@ -124,13 +161,17 @@ extern Bitboard PassedPawnMask[2][64];
|
||||||
extern Bitboard OutpostMask[2][64];
|
extern Bitboard OutpostMask[2][64];
|
||||||
|
|
||||||
#if defined(USE_COMPACT_ROOK_ATTACKS)
|
#if defined(USE_COMPACT_ROOK_ATTACKS)
|
||||||
|
|
||||||
extern Bitboard RankAttacks[8][64], FileAttacks[8][64];
|
extern Bitboard RankAttacks[8][64], FileAttacks[8][64];
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
extern const uint64_t RMult[64];
|
extern const uint64_t RMult[64];
|
||||||
extern const int RShift[64];
|
extern const int RShift[64];
|
||||||
extern Bitboard RMask[64];
|
extern Bitboard RMask[64];
|
||||||
extern int RAttackIndex[64];
|
extern int RAttackIndex[64];
|
||||||
extern Bitboard RAttacks[0x19000];
|
extern Bitboard RAttacks[0x19000];
|
||||||
|
|
||||||
#endif // defined(USE_COMPACT_ROOK_ATTACKS)
|
#endif // defined(USE_COMPACT_ROOK_ATTACKS)
|
||||||
|
|
||||||
extern const uint64_t BMult[64];
|
extern const uint64_t BMult[64];
|
||||||
|
@ -212,7 +253,7 @@ inline Bitboard this_and_neighboring_files_bb(Square s) {
|
||||||
|
|
||||||
/// relative_rank_bb() takes a color and a rank as input, and returns a bitboard
|
/// relative_rank_bb() takes a color and a rank as input, and returns a bitboard
|
||||||
/// representing all squares on the given rank from the given color's point of
|
/// representing all squares on the given rank from the given color's point of
|
||||||
/// view. For instance, relative_rank_bb(WHITE, 7) gives all squares on the
|
/// view. For instance, relative_rank_bb(WHITE, 7) gives all squares on the
|
||||||
/// 7th rank, while relative_rank_bb(BLACK, 7) gives all squares on the 2nd
|
/// 7th rank, while relative_rank_bb(BLACK, 7) gives all squares on the 2nd
|
||||||
/// rank.
|
/// rank.
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,6 @@
|
||||||
#if !defined(COLOR_H_INCLUDED)
|
#if !defined(COLOR_H_INCLUDED)
|
||||||
#define COLOR_H_INCLUDED
|
#define COLOR_H_INCLUDED
|
||||||
|
|
||||||
////
|
|
||||||
//// Includes
|
|
||||||
////
|
|
||||||
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
|
|
||||||
////
|
////
|
||||||
//// Types
|
//// Types
|
||||||
|
|
|
@ -38,8 +38,8 @@ enum Direction {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SignedDirection {
|
enum SignedDirection {
|
||||||
SIGNED_DIR_E = 0, SIGNED_DIR_W = 1,
|
SIGNED_DIR_E = 0, SIGNED_DIR_W = 1,
|
||||||
SIGNED_DIR_N = 2, SIGNED_DIR_S = 3,
|
SIGNED_DIR_N = 2, SIGNED_DIR_S = 3,
|
||||||
SIGNED_DIR_NE = 4, SIGNED_DIR_SW = 5,
|
SIGNED_DIR_NE = 4, SIGNED_DIR_SW = 5,
|
||||||
SIGNED_DIR_NW = 6, SIGNED_DIR_SE = 7,
|
SIGNED_DIR_NW = 6, SIGNED_DIR_SE = 7,
|
||||||
SIGNED_DIR_NONE = 8
|
SIGNED_DIR_NONE = 8
|
||||||
|
@ -58,9 +58,11 @@ extern uint8_t SignedDirectionTable[64][64];
|
||||||
//// Inline functions
|
//// Inline functions
|
||||||
////
|
////
|
||||||
|
|
||||||
inline void operator++ (Direction &d, int) { d = Direction(int(d) + 1); }
|
inline void operator++ (Direction& d, int) {
|
||||||
|
d = Direction(int(d) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
inline void operator++ (SignedDirection &d, int) {
|
inline void operator++ (SignedDirection& d, int) {
|
||||||
d = SignedDirection(int(d) + 1);
|
d = SignedDirection(int(d) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,29 +27,30 @@
|
||||||
|
|
||||||
#include "material.h"
|
#include "material.h"
|
||||||
#include "pawns.h"
|
#include "pawns.h"
|
||||||
#include "position.h"
|
|
||||||
|
|
||||||
|
|
||||||
////
|
////
|
||||||
//// Types
|
//// Types
|
||||||
////
|
////
|
||||||
|
|
||||||
|
|
||||||
/// The EvalInfo struct contains various information computed and collected
|
/// The EvalInfo struct contains various information computed and collected
|
||||||
/// by the evaluation function. An EvalInfo object is passed as one of the
|
/// by the evaluation function. An EvalInfo object is passed as one of the
|
||||||
/// arguments to the evaluation function, and the search can make use of its
|
/// arguments to the evaluation function, and the search can make use of its
|
||||||
/// contents to make intelligent search decisions.
|
/// contents to make intelligent search decisions.
|
||||||
///
|
///
|
||||||
/// At the moment, this is not utilized very much: The only part of the
|
/// At the moment, this is not utilized very much: The only part of the
|
||||||
/// EvalInfo object which is used by the search is futilityMargin.
|
/// EvalInfo object which is used by the search is futilityMargin.
|
||||||
|
class Position;
|
||||||
|
|
||||||
struct EvalInfo {
|
struct EvalInfo {
|
||||||
|
|
||||||
// Middle game and endgame evaluations:
|
// Middle game and endgame evaluations
|
||||||
Value mgValue, egValue;
|
Value mgValue, egValue;
|
||||||
|
|
||||||
// Pointers to material and pawn hash table entries:
|
// Pointers to material and pawn hash table entries
|
||||||
MaterialInfo *mi;
|
MaterialInfo* mi;
|
||||||
PawnInfo *pi;
|
PawnInfo* pi;
|
||||||
|
|
||||||
// attackedBy[color][piece type] is a bitboard representing all squares
|
// attackedBy[color][piece type] is a bitboard representing all squares
|
||||||
// attacked by a given color and piece type. attackedBy[color][0] contains
|
// attacked by a given color and piece type. attackedBy[color][0] contains
|
||||||
|
@ -100,8 +101,8 @@ struct EvalInfo {
|
||||||
//// Prototypes
|
//// Prototypes
|
||||||
////
|
////
|
||||||
|
|
||||||
extern Value evaluate(const Position &pos, EvalInfo &ei, int threadID);
|
extern Value evaluate(const Position& pos, EvalInfo& ei, int threadID);
|
||||||
extern Value quick_evaluate(const Position &pos);
|
extern Value quick_evaluate(const Position& pos);
|
||||||
extern void init_eval(int threads);
|
extern void init_eval(int threads);
|
||||||
extern void quit_eval();
|
extern void quit_eval();
|
||||||
extern void read_weights(Color sideToMove);
|
extern void read_weights(Color sideToMove);
|
||||||
|
|
|
@ -87,7 +87,7 @@ typedef pthread_mutex_t Lock;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
# include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
typedef CRITICAL_SECTION Lock;
|
typedef CRITICAL_SECTION Lock;
|
||||||
# define lock_init(x, y) InitializeCriticalSection(x)
|
# define lock_init(x, y) InitializeCriticalSection(x)
|
||||||
|
|
|
@ -52,7 +52,6 @@ int main(int argc, char *argv[]) {
|
||||||
std::cin.rdbuf()->pubsetbuf(NULL, 0);
|
std::cin.rdbuf()->pubsetbuf(NULL, 0);
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
|
|
||||||
init_mersenne();
|
init_mersenne();
|
||||||
init_direction_table();
|
init_direction_table();
|
||||||
init_bitboards();
|
init_bitboards();
|
||||||
|
@ -73,7 +72,7 @@ int main(int argc, char *argv[]) {
|
||||||
{
|
{
|
||||||
if (argc < 4 || argc > 7)
|
if (argc < 4 || argc > 7)
|
||||||
{
|
{
|
||||||
std::cout << "Usage: glaurung bench <hash size> <threads> "
|
std::cout << "Usage: stockfish bench <hash size> <threads> "
|
||||||
<< "[time = 60s] [fen positions file = default] "
|
<< "[time = 60s] [fen positions file = default] "
|
||||||
<< "[time, depth or node limited = time]"
|
<< "[time, depth or node limited = time]"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
|
@ -139,7 +139,7 @@ const std::string move_to_string(Move move) {
|
||||||
|
|
||||||
/// Overload the << operator, to make it easier to print moves.
|
/// Overload the << operator, to make it easier to print moves.
|
||||||
|
|
||||||
std::ostream &operator << (std::ostream &os, Move m) {
|
std::ostream &operator << (std::ostream& os, Move m) {
|
||||||
|
|
||||||
return os << move_to_string(m);
|
return os << move_to_string(m);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,12 +32,12 @@
|
||||||
//// Prototypes
|
//// Prototypes
|
||||||
////
|
////
|
||||||
|
|
||||||
extern int generate_captures(const Position &pos, MoveStack *mlist);
|
extern int generate_captures(const Position& pos, MoveStack* mlist);
|
||||||
extern int generate_noncaptures(const Position &pos, MoveStack *mlist);
|
extern int generate_noncaptures(const Position& pos, MoveStack* mlist);
|
||||||
extern int generate_checks(const Position &pos, MoveStack *mlist, Bitboard dc);
|
extern int generate_checks(const Position& pos, MoveStack* mlist, Bitboard dc);
|
||||||
extern int generate_evasions(const Position &pos, MoveStack *mlist, Bitboard pinned);
|
extern int generate_evasions(const Position& pos, MoveStack* mlist, Bitboard pinned);
|
||||||
extern int generate_legal_moves(const Position &pos, MoveStack *mlist);
|
extern int generate_legal_moves(const Position& pos, MoveStack* mlist);
|
||||||
extern bool move_is_legal(const Position &pos, const Move m, Bitboard pinned);
|
extern bool move_is_legal(const Position& pos, const Move m, Bitboard pinned);
|
||||||
|
|
||||||
|
|
||||||
#endif // !defined(MOVEGEN_H_INCLUDED)
|
#endif // !defined(MOVEGEN_H_INCLUDED)
|
||||||
|
|
|
@ -105,7 +105,6 @@ private:
|
||||||
/// a single reply to check.
|
/// a single reply to check.
|
||||||
|
|
||||||
inline int MovePicker::number_of_moves() const {
|
inline int MovePicker::number_of_moves() const {
|
||||||
|
|
||||||
return numOfMoves;
|
return numOfMoves;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "pawns.h"
|
#include "pawns.h"
|
||||||
|
#include "position.h"
|
||||||
|
|
||||||
|
|
||||||
////
|
////
|
||||||
|
|
21
src/pawns.h
21
src/pawns.h
|
@ -25,8 +25,8 @@
|
||||||
//// Includes
|
//// Includes
|
||||||
////
|
////
|
||||||
|
|
||||||
#include "position.h"
|
#include "bitboard.h"
|
||||||
|
#include "value.h"
|
||||||
|
|
||||||
////
|
////
|
||||||
//// Types
|
//// Types
|
||||||
|
@ -38,6 +38,7 @@
|
||||||
/// to add further information in the future. A lookup to the pawn hash table
|
/// to add further information in the future. A lookup to the pawn hash table
|
||||||
/// (performed by calling the get_pawn_info method in a PawnInfoTable object)
|
/// (performed by calling the get_pawn_info method in a PawnInfoTable object)
|
||||||
/// returns a pointer to a PawnInfo object.
|
/// returns a pointer to a PawnInfo object.
|
||||||
|
class Position;
|
||||||
|
|
||||||
class PawnInfo {
|
class PawnInfo {
|
||||||
|
|
||||||
|
@ -49,9 +50,9 @@ public:
|
||||||
Value kingside_storm_value(Color c) const;
|
Value kingside_storm_value(Color c) const;
|
||||||
Value queenside_storm_value(Color c) const;
|
Value queenside_storm_value(Color c) const;
|
||||||
Bitboard passed_pawns() const;
|
Bitboard passed_pawns() const;
|
||||||
bool file_is_half_open(Color c, File f) const;
|
int file_is_half_open(Color c, File f) const;
|
||||||
bool has_open_file_to_left(Color c, File f) const;
|
int has_open_file_to_left(Color c, File f) const;
|
||||||
bool has_open_file_to_right(Color c, File f) const;
|
int has_open_file_to_right(Color c, File f) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clear();
|
void clear();
|
||||||
|
@ -75,11 +76,11 @@ public:
|
||||||
PawnInfoTable(unsigned numOfEntries);
|
PawnInfoTable(unsigned numOfEntries);
|
||||||
~PawnInfoTable();
|
~PawnInfoTable();
|
||||||
void clear();
|
void clear();
|
||||||
PawnInfo *get_pawn_info(const Position &pos);
|
PawnInfo* get_pawn_info(const Position& pos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned size;
|
unsigned size;
|
||||||
PawnInfo *entries;
|
PawnInfo* entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,15 +108,15 @@ inline Value PawnInfo::queenside_storm_value(Color c) const {
|
||||||
return Value(qsStormValue[c]);
|
return Value(qsStormValue[c]);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool PawnInfo::file_is_half_open(Color c, File f) const {
|
inline int PawnInfo::file_is_half_open(Color c, File f) const {
|
||||||
return (halfOpenFiles[c] & (1 << int(f)));
|
return (halfOpenFiles[c] & (1 << int(f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool PawnInfo::has_open_file_to_left(Color c, File f) const {
|
inline int PawnInfo::has_open_file_to_left(Color c, File f) const {
|
||||||
return halfOpenFiles[c] & ((1 << int(f)) - 1);
|
return halfOpenFiles[c] & ((1 << int(f)) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool PawnInfo::has_open_file_to_right(Color c, File f) const {
|
inline int PawnInfo::has_open_file_to_right(Color c, File f) const {
|
||||||
return halfOpenFiles[c] & ~((1 << int(f+1)) - 1);
|
return halfOpenFiles[c] & ~((1 << int(f+1)) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
34
src/phase.h
34
src/phase.h
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
|
||||||
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
|
|
||||||
Copyright (C) 2008 Marco Costalba
|
|
||||||
|
|
||||||
Stockfish is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Stockfish is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#if !defined(PHASE_H_INCLUDED)
|
|
||||||
#define PHASE_H_INCLUDED
|
|
||||||
|
|
||||||
////
|
|
||||||
//// Types
|
|
||||||
////
|
|
||||||
|
|
||||||
enum Phase {
|
|
||||||
PHASE_ENDGAME = 0,
|
|
||||||
PHASE_MIDGAME = 128
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // !defined(PHASE_H_INCLUDED)
|
|
36
src/piece.h
36
src/piece.h
|
@ -26,7 +26,6 @@
|
||||||
////
|
////
|
||||||
|
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "misc.h"
|
|
||||||
#include "square.h"
|
#include "square.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,41 +49,10 @@ enum Piece {
|
||||||
//// Constants
|
//// Constants
|
||||||
////
|
////
|
||||||
|
|
||||||
const PieceType PieceTypeMin = PAWN;
|
|
||||||
const PieceType PieceTypeMax = KING;
|
|
||||||
|
|
||||||
const int SlidingArray[18] = {
|
const int SlidingArray[18] = {
|
||||||
0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0
|
0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
const SquareDelta Directions[16][16] = {
|
|
||||||
{DELTA_ZERO},
|
|
||||||
{DELTA_NW, DELTA_NE, DELTA_ZERO},
|
|
||||||
{DELTA_SSW, DELTA_SSE, DELTA_SWW, DELTA_SEE,
|
|
||||||
DELTA_NWW, DELTA_NEE, DELTA_NNW, DELTA_NNE, DELTA_ZERO},
|
|
||||||
{DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
|
|
||||||
{DELTA_S, DELTA_E, DELTA_W, DELTA_N, DELTA_ZERO},
|
|
||||||
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
|
|
||||||
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
|
|
||||||
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
|
|
||||||
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
|
|
||||||
{DELTA_ZERO},
|
|
||||||
{DELTA_ZERO},
|
|
||||||
{DELTA_SW, DELTA_SE, DELTA_ZERO},
|
|
||||||
{DELTA_SSW, DELTA_SSE, DELTA_SWW, DELTA_SEE,
|
|
||||||
DELTA_NWW, DELTA_NEE, DELTA_NNW, DELTA_NNE, DELTA_ZERO},
|
|
||||||
{DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
|
|
||||||
{DELTA_S, DELTA_E, DELTA_W, DELTA_N, DELTA_ZERO},
|
|
||||||
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
|
|
||||||
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
|
|
||||||
{DELTA_S, DELTA_E, DELTA_W, DELTA_N,
|
|
||||||
DELTA_SE, DELTA_SW, DELTA_NE, DELTA_NW, DELTA_ZERO},
|
|
||||||
};
|
|
||||||
|
|
||||||
const SquareDelta PawnPush[2] = {
|
|
||||||
DELTA_N, DELTA_S
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
////
|
////
|
||||||
//// Inline functions
|
//// Inline functions
|
||||||
|
@ -115,12 +83,12 @@ inline int piece_is_slider(Piece p) {
|
||||||
return SlidingArray[int(p)];
|
return SlidingArray[int(p)];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int piece_type_is_slider(PieceType pt) {
|
inline int piece_is_slider(PieceType pt) {
|
||||||
return SlidingArray[int(pt)];
|
return SlidingArray[int(pt)];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline SquareDelta pawn_push(Color c) {
|
inline SquareDelta pawn_push(Color c) {
|
||||||
return PawnPush[c];
|
return (c == WHITE ? DELTA_N : DELTA_S);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool piece_type_is_ok(PieceType pc) {
|
inline bool piece_type_is_ok(PieceType pc) {
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include "direction.h"
|
#include "direction.h"
|
||||||
#include "move.h"
|
#include "move.h"
|
||||||
#include "piece.h"
|
#include "piece.h"
|
||||||
#include "phase.h"
|
|
||||||
#include "square.h"
|
#include "square.h"
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
||||||
|
@ -61,7 +60,7 @@ const int MaxGameLength = 220;
|
||||||
//// Types
|
//// Types
|
||||||
////
|
////
|
||||||
|
|
||||||
/// Castle rights, encoded as bit fields:
|
/// Castle rights, encoded as bit fields
|
||||||
|
|
||||||
enum CastleRights {
|
enum CastleRights {
|
||||||
NO_CASTLES = 0,
|
NO_CASTLES = 0,
|
||||||
|
@ -72,6 +71,12 @@ enum CastleRights {
|
||||||
ALL_CASTLES = 15
|
ALL_CASTLES = 15
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Game phase
|
||||||
|
enum Phase {
|
||||||
|
PHASE_ENDGAME = 0,
|
||||||
|
PHASE_MIDGAME = 128
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/// The StateInfo struct stores information we need to restore a Position
|
/// The StateInfo struct stores information we need to restore a Position
|
||||||
/// object to its previous state when we retract a move. Whenever a move
|
/// object to its previous state when we retract a move. Whenever a move
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
//// Includes
|
//// Includes
|
||||||
////
|
////
|
||||||
|
|
||||||
#include "position.h"
|
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,21 +2,21 @@
|
||||||
(c) Copyright 1992 Eric Backus
|
(c) Copyright 1992 Eric Backus
|
||||||
|
|
||||||
This software may be used freely so long as this copyright notice is
|
This software may be used freely so long as this copyright notice is
|
||||||
left intact. There is no warrantee on this software.
|
left intact. There is no warrantee on this software.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "dos.h"
|
#include "dos.h"
|
||||||
|
|
||||||
|
int gettimeofday(struct timeval* tp, struct timezone* tzp)
|
||||||
int gettimeofday(struct timeval * tp, struct timezone * tzp)
|
|
||||||
{
|
{
|
||||||
SYSTEMTIME systime;
|
SYSTEMTIME systime;
|
||||||
|
|
||||||
if (tp) {
|
|
||||||
struct tm tmrec;
|
|
||||||
time_t theTime = time(NULL);
|
|
||||||
|
|
||||||
|
if (tp)
|
||||||
|
{
|
||||||
|
struct tm tmrec;
|
||||||
|
time_t theTime = time(NULL);
|
||||||
|
|
||||||
tmrec = *localtime(&theTime);
|
tmrec = *localtime(&theTime);
|
||||||
tp->tv_sec = mktime(&tmrec);
|
tp->tv_sec = mktime(&tmrec);
|
||||||
|
|
Loading…
Add table
Reference in a new issue