Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
osl
eval
ml
piecePairKing.h
Go to the documentation of this file.
1
/* piecePairKing.h
2
*/
3
#ifndef OSL_EVAL_ML_PIECEPAIRKING_H
4
#define OSL_EVAL_ML_PIECEPAIRKING_H
5
6
#include "
osl/state/numEffectState.h
"
7
#include <boost/cstdint.hpp>
8
namespace
osl
9
{
10
namespace
eval
11
{
12
namespace
ml
13
{
14
struct
Weights;
15
class
PiecePairKing
16
{
17
public
:
18
enum
19
{
20
ONE_DIM
= 1488375,
21
DIM
=
ONE_DIM
22
};
23
static
void
setUp
(
const
Weights
&weights);
24
static
CArray<int,2>
eval
(
const
NumEffectState&);
25
template
<Player P>
26
static
void
evalWithUpdateBang
(
const
NumEffectState& state,
Move
moved, CArray<int,2>& last_value);
27
28
template
<Player King>
29
static
int
evalOne
(
const
NumEffectState&);
30
private
:
31
template
<Player King>
32
static
int
add
(
const
NumEffectState& state,
Square
to,
Ptype
ptype);
33
template
<Player King>
34
static
int
sub
(
const
NumEffectState& state,
Square
from,
Ptype
ptype);
35
template
<Player King>
36
static
int
addSub
(
const
NumEffectState& state,
Square
to,
Ptype
ptype,
Square
from);
37
static
int
composeIndex
(
int
king,
int
i0,
int
i1)
38
{
39
return
king + i0*45*7 + i1;
40
}
41
static
int
indexWhite
(
Square
p)
42
{
43
return
p.
x
()-1 + (p.
y
()-1)*9;
44
}
45
static
int
indexKing
(
Player
owner,
Square
king,
bool
& flipx)
46
{
47
if
(owner ==
BLACK
)
48
king = king.
rotate180
();
49
assert(king.
y
() <= 3);
50
if
(king.
x
() > 5)
51
{
52
king = king.
flipHorizontal
();
53
flipx =
true
;
54
}
55
else
56
flipx =
false
;
57
return
(king.
x
()-1 + (king.
y
()-1)*5)*45*7*45*7;
58
}
59
template
<
bool
FlipX>
60
static
int
indexPiece
(
Player
owner,
Square
position,
Ptype
ptype)
61
{
62
assert(!
isPromoted
(ptype));
63
if
(owner ==
BLACK
)
64
position = position.
rotate180
();
65
if
(FlipX)
66
position = position.
flipHorizontal
();
67
assert(position.
y
() <= 5);
68
return
indexWhite
(position)*7 + ptype-
PTYPE_BASIC_MIN
-1;
69
}
70
static
osl::CArray<int16_t, ONE_DIM>
table
;
71
};
72
}
73
}
74
}
75
76
77
#endif
/* OSL_EVAL_ML_PIECEPAIRKING_H */
78
// ;;; Local Variables:
79
// ;;; mode:c++
80
// ;;; c-basic-offset:2
81
// ;;; End:
Generated on Sun Jul 21 2013 13:37:26 by
1.8.4