Skip to content

Commit

Permalink
Made MAX_MOVES into a uci option.
Browse files Browse the repository at this point in the history
  • Loading branch information
dpldgr committed Nov 10, 2024
1 parent fa94454 commit 9d3554a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/movegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

namespace Stockfish {

size_t MAX_MOVES = 1024;
size_t moveListSize = sizeof(ExtMove) * MAX_MOVES;

namespace {

template<MoveType T>
Expand Down
6 changes: 3 additions & 3 deletions src/movegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ inline bool operator<(const ExtMove& f, const ExtMove& s) {
template<GenType>
ExtMove* generate(const Position& pos, ExtMove* moveList);

constexpr size_t moveListSize = sizeof(ExtMove) * MAX_MOVES;
extern size_t moveListSize;

/// The MoveList struct is a simple wrapper around generate(). It sometimes comes
/// in handy to use this class instead of the low level generate() function.
template<GenType T>
struct MoveList {


#ifdef USE_HEAP_INSTEAD_OF_STACK_FOR_MOVE_LIST
explicit MoveList(const Position& pos)
{
Expand All @@ -85,7 +85,7 @@ struct MoveList {
;
}
#endif

const ExtMove* begin() const { return moveList; }
const ExtMove* end() const { return last; }
size_t size() const { return last - moveList; }
Expand Down
10 changes: 2 additions & 8 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,10 @@ constexpr int SQUARE_BITS = 6;
#endif

//When defined, move list will be stored in heap. Delete this if you want to use stack to store move list. Using stack can cause overflow (Segmentation Fault) when the search is too deep.
//#define USE_HEAP_INSTEAD_OF_STACK_FOR_MOVE_LIST
#define USE_HEAP_INSTEAD_OF_STACK_FOR_MOVE_LIST

#ifdef ALLVARS
constexpr int MAX_MOVES = 8*1024;
extern int MAX_MOVES;
constexpr int MAX_PLY = 246;
#else
constexpr int MAX_MOVES = 512;
constexpr int MAX_PLY = 246;
#endif
/// endif ALLVARS

/// A move needs 16 bits to be stored
///
Expand Down
4 changes: 3 additions & 1 deletion src/ucioption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void on_clear_hash(const Option&) { Search::clear(); }
void on_hash_size(const Option& o) { TT.resize(size_t(o)); }
void on_logger(const Option& o) { start_logger(o); }
void on_stack_size(const Option& o) { TH_STACK_SIZE=size_t(o)*1024*1024; }
void on_max_moves(const Option& o) { MAX_MOVES = size_t(o); }
void on_threads(const Option& o) { Threads.set(size_t(o)); }
void on_tb_path(const Option& o) { Tablebases::init(o); }

Expand Down Expand Up @@ -183,7 +184,8 @@ void init(OptionsMap& o) {

o["Debug Log File"] << Option("", on_logger);
o["Threads"] << Option(1, 1, 512, on_threads);
o["Stack Size"] << Option(8, 1, 64, on_stack_size);
o["StackSize"] << Option(8, 1, 64, on_stack_size);
o["MaxMoves"] << Option(1024, 256, 8192, on_max_moves);
o["Hash"] << Option(16, 1, MaxHashMB, on_hash_size);
o["Clear Hash"] << Option(on_clear_hash);
o["Ponder"] << Option(false);
Expand Down

0 comments on commit 9d3554a

Please sign in to comment.