LCOV - code coverage report
Current view: top level - Source - com.hpp (source / functions) Coverage Total Hit
Test: coverage Lines: 100.0 % 1 1
Test Date: 2026-03-02 16:42:41 Functions: - 0 0

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include "definition.hpp"
       4              : #include "logging.hpp"
       5              : #include "position.hpp"
       6              : 
       7              : /*!
       8              :  * Common tools for communication protocol (UCI and XBOARD)
       9              :  * Initialy made only for XBOARD
      10              :  * UCI shall be state less but is not totally here
      11              :  */
      12              : namespace COM {
      13              : 
      14              : enum Protocol : uint8_t { p_uci = 0, p_xboard, p_pretty };
      15              : extern Protocol protocol;
      16              : 
      17              : enum State : uint8_t { st_pondering = 0, st_analyzing, st_searching, st_none };
      18              : extern State state;
      19              : 
      20              : extern std::string       command; // see readLine, filled in COM, used in uci & xboard impl
      21              : extern RootPosition      position; // current analyzed position
      22              : extern DepthType         depth;
      23              : 
      24              : extern std::mutex mutexGUI;
      25              : 
      26              : struct GameInfo {
      27           39 :     struct GameStateInfo {
      28              :        Position p;
      29              :        Move lastMove; // the move that has been played to reach this position
      30              :     };
      31              :     
      32              :     std::vector<GameStateInfo> _gameStates;
      33              :     
      34              :     Position initialPos; ///@todo shall be RootPosition ??? This is the first position after a new game
      35              : 
      36              :     void clear(const Position & initial);
      37              : 
      38              :     void append(const GameStateInfo & stateInfo);
      39              : 
      40              :     size_t size() const;
      41              : 
      42              :     [[nodiscard]] std::vector<Move> getMoves() const;
      43              : 
      44              :     [[nodiscard]] std::optional<Hash> getHash(uint16_t halfmove) const;
      45              : 
      46              :     [[nodiscard]] std::optional<Move> getMove(uint16_t halfmove) const;
      47              : 
      48              :     [[nodiscard]] std::optional<Position> getPosition(uint16_t halfmove) const;
      49              : 
      50              :     void write(std::ostream & os) const;
      51              : };
      52              : 
      53              : [[nodiscard]] GameInfo & GetGameInfo();
      54              : 
      55              : void init(const Protocol pr);
      56              : 
      57              : void readLine();
      58              : 
      59              : [[nodiscard]] bool makeMove(const Move m, const bool disp, const std::string & tag, const Move pondermove = INVALIDMOVE);
      60              : 
      61              : void stop();
      62              : 
      63              : void stopPonder();
      64              : 
      65              : [[nodiscard]] bool receiveMoves(const Move bestmove, Move pondermove);
      66              : 
      67              : void thinkAsync(const State givenState);
      68              : 
      69              : [[nodiscard]] Move moveFromCOM(const std::string & mstr);
      70              : 
      71              : } // namespace COM
      72              : 
      73              : namespace Pretty{
      74              : inline void init() {
      75              :    Logging::ct = Logging::CT_pretty;
      76              :    Logging::LogIt(Logging::logInfo) << "Init pretty mode";
      77              :    COM::init(COM::p_pretty);
      78              : } 
      79              : }
        

Generated by: LCOV version 2.0-1