Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
osl
search
searchBase.h
Go to the documentation of this file.
1
/* searchBase.h
2
*/
3
#ifndef OSL_SEARCHBASE_H
4
#define OSL_SEARCHBASE_H
5
6
#include "
osl/search/searchRecorder.h
"
7
#include "
osl/search/searchTable.h
"
8
#include "
osl/search/realizationProbability.h
"
9
#include "
osl/search/simpleHashRecord.h
"
10
#include "
osl/search/searchWindow.h
"
11
#include "
osl/search/fixedEval.h
"
12
#include "
osl/hash/hashCollision.h
"
13
#include "
osl/hash/hashKey.h
"
14
#include "
osl/state/numEffectState.h
"
15
#include <cassert>
16
namespace
osl
17
{
18
namespace
search
19
{
20
class
SimpleHashTable;
21
26
template
<
typename
Eval,
27
typename
Table,
typename
Recorder,
typename
Probabilities>
28
struct
SearchBase
:
protected
FixedEval
29
{
30
// types
31
typedef
Eval
eval_t
;
32
33
typedef
Probabilities
Probabilities_t
;
34
protected
:
35
Recorder&
recorder
;
36
Table *
table
;
// acquaintance
37
public
:
38
SearchBase
(Recorder& r, Table *t)
39
:
recorder
(r),
table
(t)
40
{
41
assert(
table
);
42
assert(
winThreshold
(
BLACK
) > eval_t::infty());
43
}
44
virtual
~SearchBase
() {}
45
virtual
bool
abort
(
Move
)
const
{
return
false
; }
46
55
bool
validTableMove
(
const
NumEffectState& state,
56
const
MoveLogProb
& move,
int
limit
)
const
57
{
58
if
((limit < move.
logProb
()) || (! move.
validMove
()))
59
return
false
;
60
if
(! move.
isNormal
())
61
return
false
;
62
const
bool
valid
63
= ((move.
player
() == state.turn())
64
&& state.isAlmostValidMove<
false
>(move.
move
()));
65
if
(! valid)
66
{
67
// 本来ここに来てはいけない
68
recorder
.recordInvalidMoveInTable(state, move, limit);
69
throw
hash::HashCollision
();
70
}
71
return
valid;
72
}
73
private
:
74
void
recordCheckmateResult
(
Player
P,
SimpleHashRecord
*record,
75
int
val,
Move
move)
const
76
{
77
assert(
isWinValue
(P,val) ||
isWinValue
(
alt
(P),val));
78
const
int
limit
=
SearchTable::CheckmateSpecialDepth
;
79
const
MoveLogProb
best_move(move, 101);
80
recorder
.tableStoreLowerBound(P, best_move, val, limit);
81
recorder
.tableStoreUpperBound(P, best_move, val, limit);
82
record->
setAbsoluteValue
(best_move.
move
(), val,
83
SearchTable::CheckmateSpecialDepth
);
84
}
85
public
:
87
void
recordWinByCheckmate
(
Player
P,
SimpleHashRecord
*record,
88
Move
check_move)
const
89
{
90
assert(record);
91
recordCheckmateResult
(P, record,
winByCheckmate
(P), check_move);
92
}
94
void
recordLoseByCheckmate
(
Player
P,
SimpleHashRecord
*record)
const
95
{
96
assert(record);
97
recordCheckmateResult
(P, record,
winByCheckmate
(
alt
(P)),
Move::INVALID
());
98
}
99
100
using
FixedEval::isWinValue
;
101
using
FixedEval::winByCheckmate
;
102
using
FixedEval::winByFoul
;
103
using
FixedEval::winByLoop
;
104
using
FixedEval::minusInfty
;
105
using
FixedEval::drawValue
;
106
107
};
108
}
// namespace search
109
}
// namespace osl
110
111
112
#endif
/* OSL_SEARCHBASE_H */
113
// ;;; Local Variables:
114
// ;;; mode:c++
115
// ;;; c-basic-offset:2
116
// ;;; End:
Generated on Sun Jul 21 2013 13:37:26 by
1.8.4