Belofte version 2.1.9
A promising chess program using the UCI or Winboard interface
configurablegame.cpp
Go to the documentation of this file.
1/*---------------------------------------------------------------------+
2 * File: configurablegame.cpp
3 * Project: part of belofte - A Promising Chess Program
4 * Author: yves
5 * SPDX-License-Identifier: GPL-2.0-only
6+----------------------------------------------------------------------*/
7
8#include "belofte.h"
9
15
17{
18 clearAlgorithm();
19 clearEval();
20}
21
22void bConfigurableGame::setAlgorithm(std::string const& alg)
23{
24 clearAlgorithm();
25 if (alg == "Random") {
26 m_algo = new SearchRandom();
27 App().setConfig("random", 1); // random algorithm always activate random
28 Game()->getLevel().setDepthCommand(1); // and depth 1
29 } else if (alg == "StaticEval") {
30 m_algo = new SearchEvalPosOnly();
31 Game()->getLevel().setDepthCommand(1); // static eval is always depth 1
32 } else if (alg == "BruteForce") {
33 m_algo = new SearchBruteForce();
34 } else if (alg == "SearchIterativeBF") {
35 m_algo = new SearchIterativeBF();
36 } else if (alg == "AB") {
37 m_algo = new SearchAlphaBeta();
38 } else if (alg == "ABFS") {
39 m_algo = new SearchAlphaBeta();
40 } else if (alg == "ABFH") {
41 m_algo = new SearchAlphaBetaFH();
42 } else { // SearchAlphaBeta is default
43 m_algo = new SearchAlphaBeta();
44 }
45}
46
48{
49 if (m_algo == nullptr) throw std::logic_error("no algorithm defined");
50 return m_algo;
51}
52
53void bConfigurableGame::clearAlgorithm()
54{
55 if (m_algo != nullptr) delete m_algo;
56 m_algo = nullptr;
57}
58
59void bConfigurableGame::setEval(std::string const& e)
60{
61 clearEval();
62 if (e == "None") {
63 m_eval = new bPositionEvaluation();
64 } else if (e == "PiecesOnly") {
65 m_eval = new PosEvalPiecesOnly();
66 } else if (e == "StaticBoard") {
67 m_eval = new PosEvalStaticBoard();
68 } else if (e == "PositionalBoard") {
69 m_eval = new PosEvalPositionalBoard();
70 } else { // PosEvalPositionalBoard is default
71 m_eval = new PosEvalPositionalBoard();
72 }
73}
74
76{
77 if (m_eval == nullptr) throw std::logic_error("no eval defined");
78 return m_eval;
79}
80
81void bConfigurableGame::clearEval()
82{
83 if (m_eval != nullptr) delete m_eval;
84 m_eval = nullptr;
85}
86
87// eof
appInstance & App()
Definition belofte.cpp:225
bGame * Game()
Definition belofte.cpp:236
This is the main include file, needs to be included before any other include.
void setConfig(std::string const &s, int64_t v)
Definition belofte.cpp:178
void setAlgorithm(std::string const &alg)
void setEval(std::string const &e)
bSearchAlgorithm * getAlgorithm() const
bPositionEvaluation * getEval() const
bLevel & getLevel()
Definition game.h:59
void setDepthCommand(depth_t const d)
Definition level.cpp:226