Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
official-stockfish
GitHub Repository: official-stockfish/Stockfish
Path: blob/master/src/movepick.h
376 views
1
/*
2
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
3
Copyright (C) 2004-2025 The Stockfish developers (see AUTHORS file)
4
5
Stockfish is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
Stockfish is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#ifndef MOVEPICK_H_INCLUDED
20
#define MOVEPICK_H_INCLUDED
21
22
#include "history.h"
23
#include "movegen.h"
24
#include "types.h"
25
26
namespace Stockfish {
27
28
class Position;
29
30
// The MovePicker class is used to pick one pseudo-legal move at a time from the
31
// current position. The most important method is next_move(), which emits one
32
// new pseudo-legal move on every call, until there are no moves left, when
33
// Move::none() is returned. In order to improve the efficiency of the alpha-beta
34
// algorithm, MovePicker attempts to return the moves which are most likely to get
35
// a cut-off first.
36
class MovePicker {
37
38
public:
39
MovePicker(const MovePicker&) = delete;
40
MovePicker& operator=(const MovePicker&) = delete;
41
MovePicker(const Position&,
42
Move,
43
Depth,
44
const ButterflyHistory*,
45
const LowPlyHistory*,
46
const CapturePieceToHistory*,
47
const PieceToHistory**,
48
const PawnHistory*,
49
int);
50
MovePicker(const Position&, Move, int, const CapturePieceToHistory*);
51
Move next_move();
52
void skip_quiet_moves();
53
54
private:
55
template<typename Pred>
56
Move select(Pred);
57
template<GenType T>
58
ExtMove* score(MoveList<T>&);
59
ExtMove* begin() { return cur; }
60
ExtMove* end() { return endCur; }
61
62
const Position& pos;
63
const ButterflyHistory* mainHistory;
64
const LowPlyHistory* lowPlyHistory;
65
const CapturePieceToHistory* captureHistory;
66
const PieceToHistory** continuationHistory;
67
const PawnHistory* pawnHistory;
68
Move ttMove;
69
ExtMove * cur, *endCur, *endBadCaptures, *endCaptures, *endGenerated;
70
int stage;
71
int threshold;
72
Depth depth;
73
int ply;
74
bool skipQuiets = false;
75
ExtMove moves[MAX_MOVES];
76
};
77
78
} // namespace Stockfish
79
80
#endif // #ifndef MOVEPICK_H_INCLUDED
81
82