Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
official-stockfish
GitHub Repository: official-stockfish/Stockfish
Path: blob/master/src/uci.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 UCI_H_INCLUDED
20
#define UCI_H_INCLUDED
21
22
#include <cstdint>
23
#include <iostream>
24
#include <string>
25
#include <string_view>
26
27
#include "engine.h"
28
#include "misc.h"
29
#include "search.h"
30
31
namespace Stockfish {
32
33
class Position;
34
class Move;
35
class Score;
36
enum Square : int8_t;
37
using Value = int;
38
39
class UCIEngine {
40
public:
41
UCIEngine(int argc, char** argv);
42
43
void loop();
44
45
static int to_cp(Value v, const Position& pos);
46
static std::string format_score(const Score& s);
47
static std::string square(Square s);
48
static std::string move(Move m, bool chess960);
49
static std::string wdl(Value v, const Position& pos);
50
static std::string to_lower(std::string str);
51
static Move to_move(const Position& pos, std::string str);
52
53
static Search::LimitsType parse_limits(std::istream& is);
54
55
auto& engine_options() { return engine.get_options(); }
56
57
private:
58
Engine engine;
59
CommandLine cli;
60
61
static void print_info_string(std::string_view str);
62
63
void go(std::istringstream& is);
64
void bench(std::istream& args);
65
void benchmark(std::istream& args);
66
void position(std::istringstream& is);
67
void setoption(std::istringstream& is);
68
std::uint64_t perft(const Search::LimitsType&);
69
70
static void on_update_no_moves(const Engine::InfoShort& info);
71
static void on_update_full(const Engine::InfoFull& info, bool showWDL);
72
static void on_iter(const Engine::InfoIter& info);
73
static void on_bestmove(std::string_view bestmove, std::string_view ponder);
74
75
void init_search_update_listeners();
76
};
77
78
} // namespace Stockfish
79
80
#endif // #ifndef UCI_H_INCLUDED
81
82