Belofte
version 2.1.8
A promising chess program using the UCI or Winboard interface
search_perft.cpp
Go to the documentation of this file.
1
/*---------------------------------------------------------------------+
2
* File: search_perft.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
10
//-----------------------------------------------------------------------
11
12
SearchPerft::SearchPerft
()
13
:
bSearchAlgorithm
(
"Perft"
)
14
{
15
}
16
17
SearchPerft::~SearchPerft
()
18
{
19
}
20
21
bScore
SearchPerft::CalcBestMove
(
bBoard
& b)
22
{
23
try
{
24
if
(
getLevel
()->getSearchDepth() == 0) {
25
m_nodes
= 1LL;
// by definition
26
}
else
{
27
CalcBestMove
(b,
getLevel
()->getSearchDepth());
28
}
29
}
catch
(...) {
throw
;
// push other exceptions down
30
}
31
return
SCORE_UNDEFINED
;
32
}
33
34
/** Do calculate # nodes from current position
35
* @param b position
36
* @param nDepth search for depth x, decreasing !!!
37
*/
38
void
SearchPerft::CalcBestMove
(
bBoard
& b,
depth_t
const
nDepth)
39
{
40
bMoveList
ml(b);
41
42
movenum_t
n_moves = ml.getNumberOfMoves();
43
if
(nDepth > 1) {
44
for
(
movenum_t
moveid = 1; moveid <= n_moves; moveid++) {
45
bMove
m(ml[moveid]);
46
bBoard
newboard(b,
const_cast<
bMove
const&
>
(m));
47
CalcBestMove
(newboard, nDepth - 1);
48
}
49
m_nonleafnodes
+= n_moves;
50
}
else
{
51
m_nodes
+= n_moves;
52
}
53
}
54
55
//-----------------------------------------------------------------------
56
57
// eof
belofte.h
This is the main include file, needs to be included before any other include.
movenum_t
uint_fast8_t movenum_t
Definition
belofte.h:109
depth_t
int_fast8_t depth_t
Definition
belofte.h:112
bScore
int16_t bScore
Definition
bestmoveinfo.h:11
SearchPerft::CalcBestMove
bScore CalcBestMove(bBoard &b) override
Definition
search_perft.cpp:21
SearchPerft::~SearchPerft
~SearchPerft() override
Definition
search_perft.cpp:17
SearchPerft::SearchPerft
SearchPerft()
Definition
search_perft.cpp:12
bBoard
board
Definition
board.h:147
bMove
Definition
move.h:69
bMoveList
Definition
movelist.h:15
bSearchAlgorithm
Definition
search.h:79
bSearchAlgorithm::getLevel
bLevel * getLevel()
Definition
search.h:117
bSearchAlgorithm::m_nonleafnodes
int64_t m_nonleafnodes
Definition
search.h:108
bSearchAlgorithm::m_nodes
int64_t m_nodes
Definition
search.h:107
SCORE_UNDEFINED
constexpr bScore SCORE_UNDEFINED
Definition
eval.h:20
src
search_perft.cpp
Generated on 10/10/2024 by
1.9.8