11#if !defined(BELOFTE_H)
16#define BELOFTE_NOUNICODE 1
31#define MYNAME "Belofte"
32#define MYLCNAME "belofte"
33#define MYVERSION "2.1.8"
34#if defined(BELOFTE_NOUNICODE)
35#define MYAUTHOR "Yves De Billoez"
37#define MYAUTHOR "Yves De Billoëz"
39#define DEVDATES "2004-2024"
40#define MYCOPYRIGHT DEVDATES " (c)"
41#define MYLICENSE "Released under the GNU GPL v2 license"
44#define MYRELEASEDATE "on 10/10/2024"
46#define MYRELEASEDATE __DATE__ " - " __TIME__
49#define MYFULLNAME MYNAME " " MYVERSION
52#define DEBUGFILE "debug-" MYLCNAME "-" MYVERSION ".log"
72#if defined(BELOFTE_NOSIGNALS)
76#if defined(CHRONO_MISSING)
90 const char * what ()
const noexcept override {
97 const char * what ()
const noexcept override {
98 return "Quit command";
157 bool attach(std::string
const& ifile);
169 std::string readLine();
171 std::string m_filename;
172 std::ifstream m_inputfile;
173 bool m_isBatch =
true;
177#pragma GCC diagnostic push
178#pragma GCC diagnostic ignored "-Wunused-parameter"
185 explicit engineInterface(std::string
const& n, std::string
const& h =
"");
194 operator std::string() const& {
return const_cast<std::string const&
>(m_name); }
196 void execute(std::string
const& command, std::string
const& params);
204 std::string
const& reason) {
206 virtual void sendError(std::string
const& error, std::string
const& description);
207 virtual void sendHelp(std::string
const& args);
209 virtual void sendDebug(
int const l, std::string
const& info) {}
214 int64_t nodes,
int nps) {}
218 depth_t const nMaxDepth, std::string
const& comment,
219 bScore const sc, int64_t
const t, int64_t
const nodes)
const {}
221 depth_t const nMaxDepth, std::string
const& comment,
223 int64_t
const nodes)
const {}
225 std::string
const&
getHint()
const {
return m_hint; }
229 bool const published =
true);
232 void initCommand(std::vector<engineUserCommand *> cmds);
237 bool m_running =
false;
244#pragma GCC diagnostic pop
251 explicit UCIMode(std::string
const& n =
"uci");
257 void sendInfo(std::string
const& info)
override;
258 void sendDebug(
int const l, std::string
const& info)
override;
265 bScore const cp)
override;
267 depth_t const nMaxDepth, std::string
const& comment,
268 bScore const sc, int64_t
const t,
269 int64_t
const nodes)
const override;
271 depth_t const nMaxDepth, std::string
const& comment,
273 int64_t
const nodes)
const override;
286 explicit XboardMode(std::string
const& n =
"xboard");
289 void sendInfo(std::string
const& info)
override;
290 void sendDebug(
int const l, std::string
const& info)
override;
292 std::string
const& reason)
override;
294 depth_t const nMaxDepth, std::string
const& comment,
295 bScore const sc, int64_t
const t,
296 int64_t
const nodes)
const override;
317 std::string
const setMode(std::string
const& iName);
318 std::string
const&
getMode()
const {
return m_interfaceName; }
322 void setConfig(std::string
const& s, int64_t v);
323 int64_t
getConfig(std::string
const& s, int64_t v);
324 void setConfig(std::string
const& s, std::string
const& v);
325 std::string
getConfig(std::string
const& s, std::string
const& v);
340 std::map<std::string, int64_t> m_settings;
341 std::map<std::string, std::string> m_stringsettings;
343 std::string m_interfaceName;
std::map< std::string, bool > commandList_t
engineInterface * AppEI()
std::map< std::string, engineUserCommand * > engineCommands_t
std::map< std::string, engineInterface * > engineInterfaces_t
void sendPrompt() override
implementation of specific implementation
void sendDebug(int const l, std::string const &info) override
void sendResult(bBoard const &b UNUSED, gameResult_t rs UNUSED) const override
bool isRunning() const override
void sendInfoScore(long long timems, bBoard const &b, bScore const cp) override
void sendInfoDepth(int depth, int seldepth, int64_t nodes, int nps) override
void sendMove(bBoard &b, bMove const &m) override
void sendInfoCurrMove(bBoard const &b, depth_t const nLogDepth, depth_t const nMaxDepth, std::string const &comment, bMove const &m, movenum_t const moveid, int64_t const nodes) const override
void sendInfoSearching(bBoard const &b, int const nLogDepth, depth_t const nMaxDepth, std::string const &comment, bScore const sc, int64_t const t, int64_t const nodes) const override
void sendInfo(std::string const &info) override
void sendDebug(int const l, std::string const &info) override
void sendInfoSearching(bBoard const &b, int const nLogDepth, depth_t const nMaxDepth, std::string const &comment, bScore const sc, int64_t const t, int64_t const nodes) const override
void sendInvalidMove(std::string const &info, std::string const &reason) override
void sendInfo(std::string const &info) override
Singleton implementation of application.
appInstance & operator=(appInstance const &)=delete
outputWriter sout
normal output
std::string const & getMode() const
void setName(char *sName)
set name of executable based on argv[0] Remove leading / and \ characters Remove trailing ....
bel_debug m_debuginterface
appInstance(appInstance const &)=delete
bel_hash m_hashEngine
read input
appInstance(appInstance &&)=delete
appInstance & operator=(appInstance &&)=delete
void setConfig(std::string const &s, int64_t v)
int64_t getConfig(std::string const &s, int64_t v)
std::string getName() const
std::string const setMode(std::string const &iName)
commandReader m_reader
searching output
game representation, singleton
bool isBatchMode()
no interactive input, mainly during start and '@' execute
commandReader & operator=(commandReader const &)=delete
commandReader(commandReader const &)=delete
bool attach(std::string const &ifile)
commandReader(commandReader &&)=delete
commandReader & operator=(commandReader &&)=delete
implementation of user interface
virtual ~engineInterface()
virtual void sendInfoSearching(bBoard const &b, int const nLogDepth, depth_t const nMaxDepth, std::string const &comment, bScore const sc, int64_t const t, int64_t const nodes) const
engineInterface & operator=(engineInterface const &)=delete
void attachCommand(belofte::stringList const &sCommands, bool const published=true)
virtual void sendResponse(std::string const &response)
virtual void sendResult(bBoard const &b, gameResult_t rs) const
engineInterface & operator=(engineInterface &&)=delete
virtual void sendInfoCurrMove(bBoard const &b, depth_t const nLogDepth, depth_t const nMaxDepth, std::string const &comment, bMove const &m, movenum_t const moveid, int64_t const nodes) const
virtual void sendDebug(int const l, std::string const &info)
engineInterface(engineInterface const &)=delete
virtual void sendInvalidMove(std::string const &info, std::string const &reason)
static engineCommands_t m_engineCommands
virtual void setRunning(bool const r)
virtual void sendMove(bBoard &b, bMove const &m)
virtual void sendHelp(std::string const &args)
Send help on command or all commands.
virtual void sendInfoScore(long long timems, bBoard const &b, bScore const cp)
engineInterface(engineInterface &&)=delete
void execute(std::string const &command, std::string const ¶ms)
virtual void sendInfo(std::string const &info)
virtual bool isRunning() const
std::string const & getHint() const
virtual void sendError(std::string const &error, std::string const &description)
virtual void sendInfoDepth(int depth, int seldepth, int64_t nodes, int nps)
virtual void sendPrompt()
output to std::cout and if required to debug and log-file
enum gameResult gameResult_t