Skip to content

Commit

Permalink
Added use endgame option.
Browse files Browse the repository at this point in the history
  • Loading branch information
phuang1024 committed Apr 1, 2021
1 parent 3159e87 commit 0a40683
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Options::Options() {
ABPassStart = 5;
ABPassMargin = 500;
MoveTimeMult = 100;
UseEndgame = true;

EvalMaterial = 100;
EvalPawnStruct = 100;
Expand Down
2 changes: 2 additions & 0 deletions src/options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ UseHashTable: type=check, default=false, whether the engine should use hash tabl
ABPassStart: type=spin, default=5, min=1, max=100, start depth where alpha and beta values are passed to next iteration.
ABPassMargin: type=spin, default=500, min=0, max=10000, add/sub offset of alpha and beta.
MoveTimeMult: type=spin, default=100, min=10, max=1000, multiplier (percent) of move time.
UseEndgame: type=check, default=true, whether to use endgame algorithms.
EvalMaterial: type=spin, default=100, min=0, max=1000, weight (percent) of material eval.
EvalPawnStruct: type=spin, default=100, min=0, max=1000, weight (percent) of pawn structure eval.
Expand All @@ -62,6 +63,7 @@ Chat: type=check, default=true, whether the engine should chat with you.
int ABPassStart;
int ABPassMargin;
int MoveTimeMult;
bool UseEndgame;

int EvalMaterial;
int EvalPawnStruct;
Expand Down
2 changes: 1 addition & 1 deletion src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace Search {

SearchInfo search(const Options& options, const Position& pos, const int& depth, const double& movetime, bool& searching) {
const int eg = Endgame::eg_type(pos);
if (eg != 0) {
if (options.UseEndgame && eg != 0) {
const vector<Move> moves = Bitboard::legal_moves(pos, Bitboard::attacked(pos, !pos.turn));
const Move best_move = Endgame::bestmove(pos, moves, eg);
return SearchInfo(1, 1, false, pos.turn ? MAX : MIN, moves.size(), 0, 0, {best_move}, 0, 0, true);
Expand Down
2 changes: 2 additions & 0 deletions src/uci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ int loop() {
cout << "option name ABPassStart type spin default 5 min 1 max 100" << "\n";
cout << "option name ABPassMargin type spin default 500 min 0 max 10000" << "\n";
cout << "option name MoveTimeMult type spin default 100 min 10 max 1000" << "\n";
cout << "option name UseEndgame type check default true" << "\n";

cout << "option name EvalMaterial type spin default 100 min 0 max 1000" << "\n";
cout << "option name EvalPawnStruct type spin default 100 min 0 max 1000" << "\n";
Expand All @@ -226,6 +227,7 @@ int loop() {
else if (name == "ABPassStart") options.ABPassStart = std::stoi(value);
else if (name == "ABPassMargin") options.ABPassMargin = std::stoi(value);
else if (name == "MoveTimeMult") options.MoveTimeMult = std::stoi(value);
else if (name == "UseEndgame") options.UseEndgame = (value == "true");

else if (name == "EvalMaterial") options.EvalMaterial = std::stoi(value);
else if (name == "EvalPawnStruct") options.EvalPawnStruct = std::stoi(value);
Expand Down

0 comments on commit 0a40683

Please sign in to comment.