Belofte version 2.2.0
A promising chess program using the UCI or Winboard interface
belofte.h
Go to the documentation of this file.
1/**
2 * @file belofte.h
3 * @brief This is the main include file, needs to be included before any other include.
4 * @copyright This program is distributed under the GNU GPL Version 2,
5 * June 1991 General Public License. See COPYING.md for more
6 * information. SPDX-License-Identifier: GPL-2.0-only
7 * Part of belofte - A Promising Chess Program
8 * @author Yves De Billoëz
9 */
10
11#if !defined(BELOFTE_H)
12#define BELOFTE_H
13
14// --------------------------------------------------------------------
15
16//#define BELOFTE_NOUNICODE 1 // the system does not support unicode, selected by default on _WIN32
17//#define INCOMPLETE_C11 // incomplete implementation of C++11, some alternative code
18
19//-----------------------------------------------------------------------
20
21#include "myplatform.h"
22
23//-----------------------------------------------------------------------
24
25//#define BELOFTE_NORANDOM 1 // disable randomness, useful for predictability
26//#define BELOFTE_UCIMODE 1 // start with UCI interface
27//#define BELOFTE_XBOARDMODE 1 // only support xboard/cecp interface
28//#define BELOFTE_NOSIGNALS 1 // suppress default signal handling
29
30// --------------------------------------------------------------------
31
32#define MYNAME "Belofte"
33#define MYLCNAME "belofte"
34#define MYVERSION "2.2.0"
35#if defined(BELOFTE_NOUNICODE)
36#define MYAUTHOR "Yves De Billoez"
37#else
38#define MYAUTHOR "Yves De Billoëz"
39#endif
40#define DEVDATES "2004-2026"
41#define MYCOPYRIGHT DEVDATES " (c)"
42#define MYLICENSE "Released under the GNU GPL v2 license"
43
44#if !defined(_DEBUG)
45#define MYRELEASEDATE "13/04/2026"
46#else
47#define MYRELEASEDATE __DATE__ " - " __TIME__
48#endif
49
50#define MYFULLNAME MYNAME " " MYVERSION
51
52#if defined(_DEBUG)
53#define DEBUGFILE "debug-" MYLCNAME "-" MYVERSION ".log"
54#endif
55
56//-----------------------------------------------------------------------
57
58#include <map>
59#include <string>
60#include <cstring>
61#include <bitset>
62#include <iostream>
63#include <fstream>
64#include <sstream>
65#include <array>
66#include <vector>
67#include <numeric>
68#include <memory>
69#include <stdexcept>
70#include <iomanip>
71#include <algorithm>
72#include <thread>
73#include <atomic>
74#include <regex>
75
76#if defined(_DEBUG)
77#include <cassert>
78#endif
79
80#if defined(BELOFTE_NOSIGNALS)
81#include <csignal>
82#endif
83
84#if defined(CHRONO_MISSING)
85#include <sys/time.h>
86#include <unistd.h>
87#else
88#include <chrono>
89#endif
90
91#if !defined(_MSC_VER)
92#include <dirent.h>
93#endif
94
95//-----------------------------------------------------------------------
96
97typedef int8_t rank_t;
98typedef int8_t column_t;
99typedef uint8_t case_t; // 0-63, 0xFF
100typedef uint16_t fromto_t; // casefrom & caseto, 0
101typedef uint32_t bmove_t; // type used by bMove with shortest representation of basic move
102typedef uint16_t plynum_t; // used to return the ply number in a position
103typedef uint_fast8_t movenum_t; // used to return id of move in movelist
104typedef uint8_t movenum50_t; // moves till last capture or pawn move
105typedef std::bitset<64> boardbitmap_t; // used for king and knightmoves
106typedef int_fast8_t depth_t; // search depth
107
108//-----------------------------------------------------------------------
109
110#include "piece.h"
111#include "usercmd.h"
112#include "bel_debug.h"
113#include "outputwriter.h"
114#include "bel_hash.h"
115#include "util.h"
116#include "level.h"
117#include "eval.h"
118#include "case.h"
119#include "searchscore.h"
120#include "basicmove.h"
121#include "move.h"
122#include "movelist.h"
123#include "fen.h"
124#include "basicboard.h"
125#include "board.h"
126#include "engineinterface.h"
127#include "commandreader.h"
128#include "coordmove.h"
129#include "pgnmove.h"
130#include "search.h"
131#include "search_random.h"
132#include "search_qsonly.h"
133#include "search_bf.h"
134#include "search_bfit.h"
135#include "search_mm.h"
136#include "search_ab.h"
137#include "search_abfh.h"
138#include "search_perft.h"
139#include "epd_testsuite.h"
140#include "configurablegame.h"
141#include "game.h"
142
143//-----------------------------------------------------------------------
144
145typedef std::map<std::string, bool> commandList_t;
146typedef std::map<std::string, engineUserCommand*> engineCommands_t;
147
148//-----------------------------------------------------------------------
149
150/**
151 * Singleton implementation of application
152 */
154public:
155 appInstance();
156 ~appInstance();
157
158 // make sure we cannot accidentally copy or assign the class by deleting
159 // the implementation
160 appInstance(appInstance const&) = delete;
164
165 std::string const setMode(std::string const& iName);
166 std::string const& getMode() const { return m_interfaceName; }
167
168 /// @remark C++17 would allow std::any to combine both
169 /// we could use a template as well
170 void setConfig(std::string const& s, int64_t v);
171 int64_t getConfig(std::string const& s, int64_t v);
172 void setConfig(std::string const& s, std::string const& v);
173 std::string getConfig(std::string const& s, std::string const& v);
174
175 static void setName(char *sName);
176 static std::string getName();
177
178 outputWriter bout; /// normal output
179 outputWriter sout; /// searching output
180 commandReader m_reader; /// read input
185
186private:
187 /// @remark C++17 would allow std::any to combine both
188 std::map<std::string, int64_t> m_settings;
189 std::map<std::string, std::string> m_stringsettings;
190 engineInterfaces_t m_engineInterfaces;
191 std::string m_interfaceName;
192};
193
196bGame *Game();
197
198#endif // defined BELOFTE_H
199
200// eof
uint32_t bmove_t
Definition belofte.h:101
appInstance & App()
Definition belofte.cpp:242
std::bitset< 64 > boardbitmap_t
Definition belofte.h:105
int8_t rank_t
Definition belofte.h:97
std::map< std::string, bool > commandList_t
Definition belofte.h:145
uint8_t movenum50_t
Definition belofte.h:104
engineInterface * AppEI()
Definition belofte.cpp:248
bGame * Game()
Definition belofte.cpp:253
int8_t column_t
Definition belofte.h:98
uint_fast8_t movenum_t
Definition belofte.h:103
uint16_t fromto_t
Definition belofte.h:100
uint8_t case_t
Definition belofte.h:99
std::map< std::string, engineUserCommand * > engineCommands_t
Definition belofte.h:146
int_fast8_t depth_t
Definition belofte.h:106
uint16_t plynum_t
Definition belofte.h:102
Singleton implementation of application.
Definition belofte.h:153
bGame * m_game
Definition belofte.h:184
appInstance & operator=(appInstance const &)=delete
outputWriter sout
normal output
Definition belofte.h:179
std::string const & getMode() const
Definition belofte.h:166
engineInterface * m_ui
Definition belofte.h:183
static void setName(char *sName)
set name of executable based on argv[0] Remove leading / and \ characters Remove trailing ....
Definition belofte.cpp:221
bel_debug m_debuginterface
Definition belofte.h:182
appInstance(appInstance const &)=delete
bel_hash m_hashEngine
read input
Definition belofte.h:181
static std::string getName()
Definition belofte.cpp:235
appInstance(appInstance &&)=delete
appInstance & operator=(appInstance &&)=delete
void setConfig(std::string const &s, int64_t v)
Definition belofte.cpp:194
outputWriter bout
Definition belofte.h:178
int64_t getConfig(std::string const &s, int64_t v)
Definition belofte.cpp:199
std::string const setMode(std::string const &iName)
Definition belofte.cpp:186
commandReader m_reader
searching output
Definition belofte.h:180
game representation, singleton
Definition game.h:20
implementation of user interface
Outputwriter class will log to debug file, stdout and log file in this order if they have been initia...
std::map< std::string, engineInterface * > engineInterfaces_t