/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Key pawnKey, materialKey;
Value npMaterial[COLOR_NB];
int castleRights, rule50, pliesFromNull;
Key pawnKey, materialKey;
Value npMaterial[COLOR_NB];
int castleRights, rule50, pliesFromNull;
Position(const Position& p, Thread* t) { *this = p; thisThread = t; }
Position(const std::string& f, bool c960, Thread* t) { set(f, c960, t); }
Position& operator=(const Position&);
Position(const Position& p, Thread* t) { *this = p; thisThread = t; }
Position(const std::string& f, bool c960, Thread* t) { set(f, c960, t); }
Position& operator=(const Position&);
Square king_square(Color c) const;
Square ep_square() const;
bool is_empty(Square s) const;
Square king_square(Color c) const;
Square ep_square() const;
bool is_empty(Square s) const;
- const Square* piece_list(Color c, PieceType pt) const;
- int piece_count(Color c, PieceType pt) const;
+ template<PieceType Pt> int count(Color c) const;
+ template<PieceType Pt> const Square* list(Color c) const;
Value non_pawn_material(Color c) const;
// Other properties of the position
Color side_to_move() const;
Value non_pawn_material(Color c) const;
// Other properties of the position
Color side_to_move() const;
bool is_chess960() const;
Thread* this_thread() const;
int64_t nodes_searched() const;
void set_nodes_searched(int64_t n);
bool is_chess960() const;
Thread* this_thread() const;
int64_t nodes_searched() const;
void set_nodes_searched(int64_t n);
// Position consistency check, for debugging
bool pos_is_ok(int* failedStep = NULL) const;
// Position consistency check, for debugging
bool pos_is_ok(int* failedStep = NULL) const;
void put_piece(Piece p, Square s);
void set_castle_right(Color c, Square rfrom);
void put_piece(Piece p, Square s);
void set_castle_right(Color c, Square rfrom);
- // Helper template functions
- template<bool Do> void do_castle_move(Move m);
- template<bool FindPinned> Bitboard hidden_checkers() const;
+ // Helper functions
+ void do_castle(Square kfrom, Square kto, Square rfrom, Square rto);
+ Bitboard hidden_checkers(Square ksq, Color c) const;
-inline int Position::piece_count(Color c, PieceType pt) const {
- return pieceCount[c][pt];
+template<PieceType Pt> inline int Position::count(Color c) const {
+ return pieceCount[c][Pt];
-inline const Square* Position::piece_list(Color c, PieceType pt) const {
- return pieceList[c][pt];
+template<PieceType Pt> inline const Square* Position::list(Color c) const {
+ return pieceList[c][Pt];