Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
osl
search
searchRecorder.h
Go to the documentation of this file.
1
/* searchRecorder.h
2
*/
3
#ifndef _MTDF_RECORDER_H
4
#define _MTDF_RECORDER_H
5
6
#include "
osl/player.h
"
7
#include "
osl/move.h
"
8
#include "
osl/misc/lightMutex.h
"
9
#include <boost/scoped_ptr.hpp>
10
#include <iosfwd>
11
namespace
osl
12
{
13
class
MoveLogProb;
14
namespace
state
15
{
16
class
SimpleState;
17
}
18
namespace
search
19
{
27
class
CountRecorder
28
{
29
size_t
node_count
;
30
size_t
quiescence_count
;
31
size_t
checkmate_count
;
32
#ifdef OSL_SMP
33
mutable
LightMutex mutex;
34
#endif
35
public
:
36
CountRecorder
();
37
virtual
~CountRecorder
();
38
40
void
addNodeCount
(
int
count
=1) {
41
#if (defined OSL_SMP) && (defined OSL_USE_RACE_DETECTOR)
42
SCOPED_LOCK
(lk,mutex);
43
#endif
44
node_count
+=
count
;
45
}
46
void
addQuiescenceCount
(
int
count
=1) {
47
#if (defined OSL_SMP) && (defined OSL_USE_RACE_DETECTOR)
48
SCOPED_LOCK
(lk,mutex);
49
#endif
50
quiescence_count
+=
count
;
51
}
52
void
addCheckmateCount
(
int
count
=1) {
53
#ifdef OSL_SMP
54
SCOPED_LOCK
(lk,mutex);
55
#endif
56
checkmate_count
+=
count
;
57
}
58
void
setCheckmateCount
(
int
count
) {
59
#ifdef OSL_SMP
60
SCOPED_LOCK
(lk,mutex);
61
#endif
62
checkmate_count
=
count
;
63
}
64
65
void
resetNodeCount
();
66
size_t
nodeCount
()
const
{
67
#if (defined OSL_SMP) && (defined OSL_USE_RACE_DETECTOR)
68
SCOPED_LOCK
(lk,mutex);
69
#endif
70
return
node_count
;
71
}
72
size_t
quiescenceCount
()
const
{
73
#if (defined OSL_SMP) && (defined OSL_USE_RACE_DETECTOR)
74
SCOPED_LOCK
(lk,mutex);
75
#endif
76
return
quiescence_count
;
77
}
78
size_t
checkmateCount
()
const
{
79
#if (defined OSL_SMP) && (defined OSL_USE_RACE_DETECTOR)
80
SCOPED_LOCK
(lk,mutex);
81
#endif
82
return
checkmate_count
;
83
}
84
size_t
searchNodeCount
()
const
85
{
86
#if (defined OSL_SMP) && (defined OSL_USE_RACE_DETECTOR)
87
SCOPED_LOCK
(lk,mutex);
88
#endif
89
return
node_count
+
quiescence_count
;
90
}
91
size_t
allNodeCount
()
const
{
92
#if (defined OSL_SMP) && (defined OSL_USE_RACE_DETECTOR)
93
SCOPED_LOCK
(lk,mutex);
94
#endif
95
return
node_count
+
quiescence_count
+
checkmate_count
;
96
}
97
double
checkmateRatio
()
const
98
{
99
const
double
checkmate =
checkmateCount
();
100
const
double
search
=
searchNodeCount
();
101
return
checkmate / (checkmate +
search
);
102
}
104
void
tryMove
(
const
MoveLogProb
&
/*m*/
,
int
/*last_f*/
,
int
/*limit*/
)
const
{}
106
void
retryMove
(
const
MoveLogProb
&
/*m*/
,
int
/*last_f*/
,
int
/*limit*/
,
107
int
/*retryCount*/
)
const
{}
109
void
recordValue
(
const
MoveLogProb
&,
int
/*val*/
,
bool
/*better_move*/
,
110
int
/*limit*/
)
const
{}
111
113
void
recordTopLevelLowFail
(
const
MoveLogProb
&
/* best */
,
int
/*last_f*/
)
const
{}
114
void
recordTopLevelHighFail
(
const
MoveLogProb
&
/*best */
,
int
/*last_f*/
)
const
{}
115
116
void
tableHitLowerBound
(
Player
,
int
,
int
/*last_f*/
,
int
/*limit*/
)
const
{}
117
void
tableHitUpperBound
(
Player
,
int
,
int
/*last_f*/
,
int
/*limit*/
)
const
{}
118
119
void
tableStoreLowerBound
(
Player
,
const
MoveLogProb
&,
int
,
int
)
const
{}
120
void
tableStoreUpperBound
(
Player
,
const
MoveLogProb
&,
int
,
int
)
const
{}
121
122
123
void
startSearch
(
int
/*limit*/
)
const
{}
125
virtual
void
finishSearch
(
Move
best,
double
seconds_consumed,
126
bool
verbose
)
const
;
127
128
void
recordInvalidMoveInTable
(
const
state::SimpleState
&,
129
const
MoveLogProb
&,
int
limit
)
const
;
130
void
newCategory
(
const
char
*
/*name*/
,
int
/*limit*/
)
const
{}
131
133
void
gotoCheckmateSearch
(
const
state::SimpleState
&,
int
)
const
{}
134
void
backFromCheckmateSearch
()
const
{}
135
136
void
reportCount
(std::ostream&,
double
seconds)
const
;
137
void
reportCount
(std::ostream&)
const
;
138
};
139
140
class
SearchRecorder
:
public
CountRecorder
141
{
142
struct
Recorder
;
144
boost::scoped_ptr<Recorder>
recorder
;
145
public
:
146
explicit
SearchRecorder
(
const
char
*filename=
"mtdf.log"
);
147
~SearchRecorder
();
148
150
void
setLogMargin
(
int
margin=500);
151
152
void
tryMove
(
const
MoveLogProb
& m,
int
last_f,
int
limit
)
const
;
153
void
retryMove
(
const
MoveLogProb
& m,
int
last_f,
int
limit
,
154
int
retryCount)
const
;
155
156
void
recordValue
(
const
MoveLogProb
& m,
int
val,
bool
betterMove,
int
limit
)
const
;
157
158
void
tableHitLowerBound
(
Player
p,
int
val,
int
last_f,
int
limit
)
const
;
159
void
tableHitUpperBound
(
Player
p,
int
val,
int
last_f,
int
limit
)
const
;
160
161
void
tableStoreLowerBound
(
Player
p,
const
MoveLogProb
& best_move,
int
val,
int
limit
)
const
;
162
void
tableStoreUpperBound
(
Player
p,
const
MoveLogProb
& best_move,
int
val,
int
limit
)
const
;
163
164
void
recordTopLevelLowFail
(
const
MoveLogProb
&
/* best */
,
int
last_f)
const
;
165
void
recordTopLevelHighFail
(
const
MoveLogProb
& best_move,
int
last_f)
const
;
166
167
void
startSearch
(
int
limit
)
const
;
168
void
finishSearch
(
Move
best_move,
double
seconds_consumed,
bool
verbose
)
const
;
169
170
void
newCategory
(
const
char
*name,
int
limit
)
const
;
171
172
void
gotoCheckmateSearch
(
const
state::SimpleState
&,
int
nodeLimit)
const
;
173
void
backFromCheckmateSearch
()
const
;
174
176
std::ostream&
stream
()
const
;
177
};
178
}
// namespace search
179
180
using
search::CountRecorder
;
181
using
search::SearchRecorder
;
182
}
// namespace osl
183
184
185
#endif
/* _MTDF_RECORDER_H */
186
// ;;; Local Variables:
187
// ;;; mode:c++
188
// ;;; c-basic-offset:2
189
// ;;; End:
Generated on Sun Jul 21 2013 13:37:26 by
1.8.4