2 Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3 Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
4 Copyright (C) 2008 Marco Costalba
6 Stockfish is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 Stockfish is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #if !defined MOVEPICK_H_INCLUDED
22 #define MOVEPICK_H_INCLUDED
37 /// MovePicker is a class which is used to pick one legal move at a time from
38 /// the current position. It is initialized with a Position object and a few
39 /// moves we have reason to believe are good. The most important method is
40 /// MovePicker::pick_next_move(), which returns a new legal move each time it
41 /// is called, until there are no legal moves left, when MOVE_NONE is returned.
42 /// In order to improve the efficiency of the alpha beta algorithm, MovePicker
43 /// attempts to return the moves which are most likely to be strongest first.
50 PH_TT_MOVE, // Transposition table move
51 PH_MATE_KILLER, // Mate killer from the current ply
52 PH_GOOD_CAPTURES, // Queen promotions and captures with SEE values >= 0
53 PH_BAD_CAPTURES, // Queen promotions and captures with SEE valuse <= 0
54 PH_KILLER_1, // Killer move 1 from the current ply (not used yet).
55 PH_KILLER_2, // Killer move 2 from the current ply (not used yet).
56 PH_NONCAPTURES, // Non-captures and underpromotions
57 PH_EVASIONS, // Check evasions
58 PH_QCAPTURES, // Captures in quiescence search
59 PH_QCHECKS, // Checks in quiescence search
63 MovePicker(const Position& p, bool pvnode, Move ttm, Move mk, Move k1, Move k2, Depth d);
65 Move get_next_move(Lock &lock);
66 int number_of_moves() const;
67 int current_move_score() const;
68 MovegenPhase current_move_type() const;
69 Bitboard discovered_check_candidates() const;
71 static void init_phase_table();
74 void score_captures();
75 void score_noncaptures();
76 void score_evasions();
77 void score_qcaptures();
78 Move pick_move_from_list();
79 int find_best_index();
82 Move ttMove, mateKiller, killer1, killer2;
84 MoveStack moves[256], badCaptures[64];
88 int numOfMoves, numOfBadCaptures;
89 int movesPicked, badCapturesPicked;
98 /// MovePicker::number_of_moves() simply returns the numOfMoves member
99 /// variable. It is intended to be used in positions where the side to move
100 /// is in check, for detecting checkmates or situations where there is only
101 /// a single reply to check.
103 inline int MovePicker::number_of_moves() const {
107 /// MovePicker::discovered_check_candidates() returns a bitboard containing
108 /// all pieces which can possibly give discovered check. This bitboard is
109 /// computed by the constructor function.
111 inline Bitboard MovePicker::discovered_check_candidates() const {
115 #endif // !defined(MOVEPICK_H_INCLUDED)