Belofte version 2.1.9
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_NOSIGNALS 1 // suppress default signal handling
28
29// --------------------------------------------------------------------
30
31#define MYNAME "Belofte"
32#define MYLCNAME "belofte"
33#define MYVERSION "2.1.9"
34#if defined(BELOFTE_NOUNICODE)
35#define MYAUTHOR "Yves De Billoez"
36#else
37#define MYAUTHOR "Yves De Billoëz"
38#endif
39#define DEVDATES "2004-2025"
40#define MYCOPYRIGHT DEVDATES " (c)"
41#define MYLICENSE "Released under the GNU GPL v2 license"
42
43#if !defined(_DEBUG)
44#define MYRELEASEDATE "on 19/08/2025"
45#else
46#define MYRELEASEDATE __DATE__ " - " __TIME__
47#endif
48
49#define MYFULLNAME MYNAME " " MYVERSION
50
51#if defined(_DEBUG)
52#define DEBUGFILE "debug-" MYLCNAME "-" MYVERSION ".log"
53#endif
54
55//-----------------------------------------------------------------------
56
57#include <map>
58#include <string>
59#include <cstring>
60#include <bitset>
61#include <iostream>
62#include <fstream>
63#include <sstream>
64#include <array>
65#include <vector>
66#include <numeric>
67#include <memory>
68#include <stdexcept>
69#include <iomanip>
70#include <algorithm>
71#include <thread>
72#include <atomic>
73
74#if defined(_DEBUG)
75#include <cassert>
76#endif
77
78#if defined(BELOFTE_NOSIGNALS)
79#include <csignal>
80#endif
81
82#if defined(CHRONO_MISSING)
83#include <sys/time.h>
84#else
85#include <chrono>
86#endif
87
88#if !defined(_MSC_VER)
89#include <dirent.h>
90#endif
91
92//-----------------------------------------------------------------------
93
94typedef int8_t rank_t;
95typedef int8_t column_t;
96typedef uint8_t case_t; // 0-63, 0xFF
97typedef uint16_t fromto_t; // casefrom & caseto, 0
98typedef uint32_t bmove_t; // type used by bMove with shortest representation of basic move
99typedef uint16_t plynum_t; // used to return the ply number in a position
100typedef uint_fast8_t movenum_t; // used to return id of move in movelist
101typedef uint8_t movenum50_t; // moves till last capture or pawn move
102typedef std::bitset<64> boardbitmap_t; // used for king and knightmoves
103typedef int_fast8_t depth_t; // search depth
104
105//-----------------------------------------------------------------------
106
107#include "piece.h"
108#include "usercmd.h"
109#include "bel_debug.h"
110#include "bel_hash.h"
111#include "util.h"
112#include "level.h"
113#include "eval.h"
114#include "case.h"
115#include "searchscore.h"
116#include "basicmove.h"
117#include "move.h"
118#include "movelist.h"
119#include "fen.h"
120#include "basicboard.h"
121#include "board.h"
122#include "engineinterface.h"
123#include "commandreader.h"
124#include "coordmove.h"
125#include "pgnmove.h"
126#include "search.h"
127#include "search_random.h"
128#include "search_qsonly.h"
129#include "search_bf.h"
130#include "search_bfit.h"
131#include "search_ab.h"
132#include "search_abfh.h"
133#include "search_perft.h"
134#include "epd_testsuite.h"
135#include "configurablegame.h"
136#include "game.h"
137
138//-----------------------------------------------------------------------
139
140typedef std::map<std::string, bool> commandList_t;
141typedef std::map<std::string, engineUserCommand*> engineCommands_t;
142
143//-----------------------------------------------------------------------
144
145/**
146 * Singleton implementation of application
147 */
149public:
150 appInstance();
151 ~appInstance();
152
153 // make sure we cannot accidentally copy or assign the class by deleting
154 // the implementation
155 appInstance(appInstance const&) = delete;
159
160 std::string const setMode(std::string const& iName);
161 std::string const& getMode() const { return m_interfaceName; }
162
163 /// @remark C++17 would allow std::any to combine both
164 /// we could use a template as well
165 void setConfig(std::string const& s, int64_t v);
166 int64_t getConfig(std::string const& s, int64_t v);
167 void setConfig(std::string const& s, std::string const& v);
168 std::string getConfig(std::string const& s, std::string const& v);
169
170 void setName(char *sName);
171 std::string getName() const;
172
173 outputWriter bout; /// normal output
174 outputWriter sout; /// searching output
175 commandReader m_reader; /// read input
180
181private:
182 /// @remark C++17 would allow std::any to combine both
183 std::map<std::string, int64_t> m_settings;
184 std::map<std::string, std::string> m_stringsettings;
185 engineInterfaces_t m_engineInterfaces;
186 std::string m_interfaceName;
187};
188
191bGame *Game();
192
193#endif // defined BELOFTE_H
194
195// eof
uint32_t bmove_t
Definition belofte.h:98
appInstance & App()
Definition belofte.cpp:225
std::bitset< 64 > boardbitmap_t
Definition belofte.h:102
int8_t rank_t
Definition belofte.h:94
std::map< std::string, bool > commandList_t
Definition belofte.h:140
uint8_t movenum50_t
Definition belofte.h:101
engineInterface * AppEI()
Definition belofte.cpp:231
bGame * Game()
Definition belofte.cpp:236
int8_t column_t
Definition belofte.h:95
uint_fast8_t movenum_t
Definition belofte.h:100
uint16_t fromto_t
Definition belofte.h:97
uint8_t case_t
Definition belofte.h:96
std::map< std::string, engineUserCommand * > engineCommands_t
Definition belofte.h:141
int_fast8_t depth_t
Definition belofte.h:103
uint16_t plynum_t
Definition belofte.h:99
Singleton implementation of application.
Definition belofte.h:148
bGame * m_game
Definition belofte.h:179
appInstance & operator=(appInstance const &)=delete
outputWriter sout
normal output
Definition belofte.h:174
std::string const & getMode() const
Definition belofte.h:161
engineInterface * m_ui
Definition belofte.h:178
void setName(char *sName)
set name of executable based on argv[0] Remove leading / and \ characters Remove trailing ....
Definition belofte.cpp:204
bel_debug m_debuginterface
Definition belofte.h:177
appInstance(appInstance const &)=delete
bel_hash m_hashEngine
read input
Definition belofte.h:176
appInstance(appInstance &&)=delete
appInstance & operator=(appInstance &&)=delete
void setConfig(std::string const &s, int64_t v)
Definition belofte.cpp:178
outputWriter bout
Definition belofte.h:173
int64_t getConfig(std::string const &s, int64_t v)
Definition belofte.cpp:183
std::string getName() const
Definition belofte.cpp:218
std::string const setMode(std::string const &iName)
Definition belofte.cpp:170
commandReader m_reader
searching output
Definition belofte.h:175
game representation, singleton
Definition game.h:20
implementation of user interface
output to std::cout and if required to debug and log-file
Definition bel_debug.h:38
std::map< std::string, engineInterface * > engineInterfaces_t