/*1Stockfish, a UCI chess playing engine derived from Glaurung 2.12Copyright (C) 2004-2025 The Stockfish developers (see AUTHORS file)34Stockfish is free software: you can redistribute it and/or modify5it under the terms of the GNU General Public License as published by6the Free Software Foundation, either version 3 of the License, or7(at your option) any later version.89Stockfish is distributed in the hope that it will be useful,10but WITHOUT ANY WARRANTY; without even the implied warranty of11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12GNU General Public License for more details.1314You should have received a copy of the GNU General Public License15along with this program. If not, see <http://www.gnu.org/licenses/>.16*/1718#ifndef MOVEGEN_H_INCLUDED19#define MOVEGEN_H_INCLUDED2021#include <algorithm> // IWYU pragma: keep22#include <cstddef>2324#include "types.h"2526namespace Stockfish {2728class Position;2930enum GenType {31CAPTURES,32QUIETS,33EVASIONS,34NON_EVASIONS,35LEGAL36};3738struct ExtMove: public Move {39int value;4041void operator=(Move m) { data = m.raw(); }4243// Inhibit unwanted implicit conversions to Move44// with an ambiguity that yields to a compile error.45operator float() const = delete;46};4748inline bool operator<(const ExtMove& f, const ExtMove& s) { return f.value < s.value; }4950template<GenType>51Move* generate(const Position& pos, Move* moveList);5253// The MoveList struct wraps the generate() function and returns a convenient54// list of moves. Using MoveList is sometimes preferable to directly calling55// the lower level generate() function.56template<GenType T>57struct MoveList {5859explicit MoveList(const Position& pos) :60last(generate<T>(pos, moveList)) {}61const Move* begin() const { return moveList; }62const Move* end() const { return last; }63size_t size() const { return last - moveList; }64bool contains(Move move) const { return std::find(begin(), end(), move) != end(); }6566private:67Move moveList[MAX_MOVES], *last;68};6970} // namespace Stockfish7172#endif // #ifndef MOVEGEN_H_INCLUDED737475