Belofte version 2.1.8
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 } else if (alg == "StaticEval") {
28 m_algo = new SearchEvalPosOnly();
29 } else if (alg == "BruteForce") {
30 m_algo = new SearchBruteForce();
31 } else if (alg == "SearchIterativeBF") {
32 m_algo = new SearchIterativeBF();
33 } else if (alg == "AB") {
34 m_algo = new SearchAlphaBeta();
35 } else if (alg == "ABFS") {
36 m_algo = new SearchAlphaBeta();
37 } else if (alg == "ABFH") {
38 m_algo = new SearchAlphaBetaFH();
39 } else { // SearchAlphaBeta is default
40 m_algo = new SearchAlphaBeta();
41 }
42}
43
45{
46 if (m_algo == nullptr) throw std::logic_error("no algorithm defined");
47 return m_algo;
48}
49
50void bConfigurableGame::clearAlgorithm()
51{
52 if (m_algo != nullptr) delete m_algo;
53 m_algo = nullptr;
54}
55
56void bConfigurableGame::setEval(std::string const& e)
57{
58 clearEval();
59 if (e == "PiecesOnly") {
60 m_eval = new PosEvalPiecesOnly();
61 } else if (e == "StaticBoard") {
62 m_eval = new PosEvalStaticBoard();
63 } else if (e == "PositionalBoard") {
64 m_eval = new PosEvalPositionalBoard();
65 } else { // PosEvalPositionalBoard is default
66 m_eval = new PosEvalPositionalBoard();
67 }
68}
69
71{
72 if (m_eval == nullptr) throw std::logic_error("no eval defined");
73 return m_eval;
74}
75
76void bConfigurableGame::clearEval()
77{
78 if (m_eval != nullptr) delete m_eval;
79 m_eval = nullptr;
80}
81
82// eof
This is the main include file, needs to be included before any other include.
void setAlgorithm(std::string const &alg)
void setEval(std::string const &e)
bSearchAlgorithm * getAlgorithm() const
bPositionEvaluation * getEval() const