]> git.sesse.net Git - stockfish/blobdiff - src/uci.h
Merge remote-tracking branch 'upstream/master'
[stockfish] / src / uci.h
index 76e6cda6327512c208724685b322a75c78d47a69..23745f96a96eaefa9b34868cea21f7822d0580ad 100644 (file)
--- a/src/uci.h
+++ b/src/uci.h
@@ -1,7 +1,6 @@
 /*
   Stockfish, a UCI chess playing engine derived from Glaurung 2.1
 /*
   Stockfish, a UCI chess playing engine derived from Glaurung 2.1
-  Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
-  Copyright (C) 2008-2015 Marco Costalba, Joona Kiiski, Tord Romstad
+  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
 
   Stockfish is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#ifndef UCIOPTION_H_INCLUDED
-#define UCIOPTION_H_INCLUDED
+#ifndef UCI_H_INCLUDED
+#define UCI_H_INCLUDED
 
 
-#include <map>
+#include <cstdint>
+#include <iostream>
 #include <string>
 #include <string>
+#include <string_view>
 
 
-#include "types.h"
+#include "engine.h"
+#include "misc.h"
+#include "search.h"
 
 
-class Position;
+namespace Stockfish {
 
 
-namespace UCI {
+class Position;
+class Move;
+class Score;
+enum Square : int;
+using Value = int;
 
 
-class Option;
+class UCIEngine {
+   public:
+    UCIEngine(int argc, char** argv);
 
 
-/// Custom comparator because UCI options should be case insensitive
-struct CaseInsensitiveLess {
-  bool operator() (const std::string&, const std::string&) const;
-};
+    void loop();
 
 
-/// Our options container is actually a std::map
-typedef std::map<std::string, Option, CaseInsensitiveLess> OptionsMap;
+    static int         to_cp(Value v, const Position& pos);
+    static std::string format_score(const Score& s);
+    static std::string square(Square s);
+    static std::string move(Move m, bool chess960);
+    static std::string wdl(Value v, const Position& pos);
+    static std::string to_lower(std::string str);
+    static Move        to_move(const Position& pos, std::string str);
 
 
-/// Option class implements an option as defined by UCI protocol
-class Option {
+    static Search::LimitsType parse_limits(std::istream& is);
 
 
-  typedef void (*OnChange)(const Option&);
+    auto& engine_options() { return engine.get_options(); }
 
 
-public:
-  Option(OnChange = nullptr);
-  Option(bool v, OnChange = nullptr);
-  Option(const char* v, OnChange = nullptr);
-  Option(int v, int min, int max, OnChange = nullptr);
+   private:
+    Engine      engine;
+    CommandLine cli;
 
 
-  Option& operator=(const std::string&);
-  void operator<<(const Option&);
-  operator int() const;
-  operator std::string() const;
+    static void print_info_string(const std::string& str);
 
 
-private:
-  friend std::ostream& operator<<(std::ostream&, const OptionsMap&);
+    void          go(std::istringstream& is);
+    void          bench(std::istream& args);
+    void          position(std::istringstream& is);
+    void          setoption(std::istringstream& is);
+    std::uint64_t perft(const Search::LimitsType&);
 
 
-  std::string defaultValue, currentValue, type;
-  int min, max;
-  size_t idx;
-  OnChange on_change;
+    static void on_update_no_moves(const Engine::InfoShort& info);
+    static void on_update_full(const Engine::InfoFull& info, bool showWDL);
+    static void on_iter(const Engine::InfoIter& info);
+    static void on_bestmove(std::string_view bestmove, std::string_view ponder);
 };
 
 };
 
-void init(OptionsMap&);
-void loop(int argc, char* argv[]);
-std::string value(Value v);
-std::string square(Square s);
-std::string move(Move m, bool chess960);
-std::string pv(const Position& pos, Depth depth, Value alpha, Value beta);
-Move to_move(const Position& pos, std::string& str);
-
-} // namespace UCI
-
-extern UCI::OptionsMap Options;
+}  // namespace Stockfish
 
 
-#endif // #ifndef UCIOPTION_H_INCLUDED
+#endif  // #ifndef UCI_H_INCLUDED