mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Credit for the idea goes to peregrine on discord. Passed STC 10+0.1: https://tests.stockfishchess.org/tests/view/662652623fe04ce4cefc48cf LLR: 2.95 (-2.94,2.94) <0.00,2.00> Total: 75712 W: 19793 L: 19423 D: 36496 Ptnml(0-2): 258, 8487, 20023, 8803, 285 Passed LTC 60+0.6: https://tests.stockfishchess.org/tests/view/6627495e3fe04ce4cefc59b6 LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 49788 W: 12743 L: 12404 D: 24641 Ptnml(0-2): 29, 5141, 14215, 5480, 29 The code was updated slightly and tested for non-regression against the original code at STC: LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 41952 W: 10912 L: 10698 D: 20342 Ptnml(0-2): 133, 4825, 10835, 5061, 122 https://tests.stockfishchess.org/tests/view/662d84f56115ff6764c7e438 closes https://github.com/official-stockfish/Stockfish/pull/5189 Bench: 1836777
111 lines
3.1 KiB
C++
111 lines
3.1 KiB
C++
/*
|
|
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
|
Copyright (C) 2004-2024 The Stockfish developers (see AUTHORS file)
|
|
|
|
Stockfish is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
Stockfish is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef ENGINE_H_INCLUDED
|
|
#define ENGINE_H_INCLUDED
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#include "nnue/network.h"
|
|
#include "position.h"
|
|
#include "search.h"
|
|
#include "syzygy/tbprobe.h" // for Stockfish::Depth
|
|
#include "thread.h"
|
|
#include "tt.h"
|
|
#include "ucioption.h"
|
|
|
|
namespace Stockfish {
|
|
|
|
enum Square : int;
|
|
|
|
class Engine {
|
|
public:
|
|
using InfoShort = Search::InfoShort;
|
|
using InfoFull = Search::InfoFull;
|
|
using InfoIter = Search::InfoIteration;
|
|
|
|
Engine(std::string path = "");
|
|
~Engine() { wait_for_search_finished(); }
|
|
|
|
std::uint64_t perft(const std::string& fen, Depth depth, bool isChess960);
|
|
|
|
// non blocking call to start searching
|
|
void go(Search::LimitsType&);
|
|
// non blocking call to stop searching
|
|
void stop();
|
|
|
|
// blocking call to wait for search to finish
|
|
void wait_for_search_finished();
|
|
// set a new position, moves are in UCI format
|
|
void set_position(const std::string& fen, const std::vector<std::string>& moves);
|
|
|
|
// modifiers
|
|
|
|
void resize_threads();
|
|
void set_tt_size(size_t mb);
|
|
void set_ponderhit(bool);
|
|
void search_clear();
|
|
|
|
void set_on_update_no_moves(std::function<void(const InfoShort&)>&&);
|
|
void set_on_update_full(std::function<void(const InfoFull&)>&&);
|
|
void set_on_iter(std::function<void(const InfoIter&)>&&);
|
|
void set_on_bestmove(std::function<void(std::string_view, std::string_view)>&&);
|
|
|
|
// network related
|
|
|
|
void verify_networks() const;
|
|
void load_networks();
|
|
void load_big_network(const std::string& file);
|
|
void load_small_network(const std::string& file);
|
|
void save_network(const std::pair<std::optional<std::string>, std::string> files[2]);
|
|
|
|
// utility functions
|
|
|
|
void trace_eval() const;
|
|
OptionsMap& get_options();
|
|
std::string fen() const;
|
|
void flip();
|
|
std::string visualize() const;
|
|
|
|
private:
|
|
const std::string binaryDirectory;
|
|
|
|
Position pos;
|
|
StateListPtr states;
|
|
Square capSq;
|
|
|
|
OptionsMap options;
|
|
ThreadPool threads;
|
|
TranspositionTable tt;
|
|
Eval::NNUE::Networks networks;
|
|
|
|
Search::SearchManager::UpdateContext updateContext;
|
|
};
|
|
|
|
} // namespace Stockfish
|
|
|
|
|
|
#endif // #ifndef ENGINE_H_INCLUDED
|