/*
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
/// The checkInfo struct is initialized at c'tor time and keeps info used
/// to detect if a move gives check.
class Position;
/// The checkInfo struct is initialized at c'tor time and keeps info used
/// to detect if a move gives check.
class Position;
Key pawnKey, materialKey;
Value npMaterial[COLOR_NB];
int castleRights, rule50, pliesFromNull;
Key pawnKey, materialKey;
Value npMaterial[COLOR_NB];
int castleRights, rule50, pliesFromNull;
- Position(const std::string& f, bool c960, Thread* t) { from_fen(f, c960, t); }
+ Position(const std::string& f, bool c960, Thread* t) { set(f, c960, t); }
- void from_fen(const std::string& fen, bool isChess960, Thread* th);
- const std::string to_fen() const;
- void print(Move m = MOVE_NONE) const;
+ void set(const std::string& fen, bool isChess960, Thread* th);
+ const std::string fen() const;
+ const std::string pretty(Move m = MOVE_NONE) const;
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;
Bitboard checkers() const;
Bitboard discovered_check_candidates() const;
Bitboard pinned_pieces() const;
Bitboard checkers() const;
Bitboard discovered_check_candidates() const;
Bitboard pinned_pieces() const;
bool pl_move_is_legal(Move m, Bitboard pinned) const;
bool is_pseudo_legal(const Move m) const;
bool is_capture(Move m) const;
bool pl_move_is_legal(Move m, Bitboard pinned) const;
bool is_pseudo_legal(const Move m) const;
bool is_capture(Move m) const;
void do_move(Move m, StateInfo& st);
void do_move(Move m, StateInfo& st, const CheckInfo& ci, bool moveIsCheck);
void undo_move(Move m);
void do_move(Move m, StateInfo& st);
void do_move(Move m, StateInfo& st, const CheckInfo& ci, bool moveIsCheck);
void undo_move(Move m);
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];