Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
osl
eval
endgame
kingPieceTable.h
Go to the documentation of this file.
1
/* kingPieceTable.h
2
*/
3
#ifndef ENDGAME_KINGPIECETABLE_H
4
#define ENDGAME_KINGPIECETABLE_H
5
6
#include "
osl/piece.h
"
7
#include "
osl/misc/carray2d.h
"
8
9
namespace
osl
10
{
11
namespace
state
12
{
13
class
SimpleState;
14
}
15
namespace
container
16
{
17
class
PieceValues;
18
}
19
namespace
eval
20
{
21
namespace
endgame
22
{
23
class
KingPieceTable;
24
bool
operator==
(
const
KingPieceTable& l, KingPieceTable& r);
28
class
KingPieceTable
29
{
30
public
:
31
enum
{
EffectiveDimension
= 81*2*82*
PTYPE_SIZE
};
32
protected
:
33
CArray2d<int,Square::SIZE*2,Square::SIZE*PTYPE_SIZE>
data
;
34
KingPieceTable
() {
data
.fill(0); }
35
public
:
36
static
int
otherIndex
(
Square
other,
Ptype
ptype)
37
{
38
return
other.
index
()*
PTYPE_SIZE
+ ptype;
39
}
40
static
int
kingIndex
(
Square
king,
Player
defense)
41
{
42
return
king.
index
()*2+
playerToIndex
(defense);
43
}
44
int
&
valueOf
(
Square
king,
Player
defense,
Square
other,
Ptype
ptype)
45
{
46
return
data
[
kingIndex
(king,defense)][
otherIndex
(other,ptype)];
47
}
48
int
valueOf
(
Square
king,
Player
defense,
Square
other,
Ptype
ptype)
const
49
{
50
return
data
[
kingIndex
(king,defense)][
otherIndex
(other, ptype)];
51
}
52
static
int
effectiveIndexOf
(
Square
king,
Player
defense,
Square
other,
Ptype
ptype)
53
{
54
int
base = (((king.
x
()-1)*9+king.
y
()-1)*2+
playerToIndex
(defense));
55
int
s = other.
isPieceStand
() ? 0 : ((other.
x
()-1)*9+other.
y
());
56
return
base*82*
PTYPE_SIZE
+ s*
PTYPE_SIZE
+ ptype;
57
}
58
void
saveText
(
const
char
*filename)
const
;
59
void
loadText
(
const
char
*filename);
60
void
resetWeights
(
const
int
*w);
61
void
randomize
();
62
void
clear
();
63
static
int
dimension
() {
return
EffectiveDimension
; }
64
friend
bool
operator==
(
const
KingPieceTable
& l,
KingPieceTable
& r);
65
};
66
}
// namespace endgame
67
}
// namespace endgame
68
}
// namespace osl
69
70
71
#endif
/* ENDGAME_KINGPIECETABLE_H */
72
// ;;; Local Variables:
73
// ;;; mode:c++
74
// ;;; c-basic-offset:2
75
// ;;; coding:utf-8
76
// ;;; End:
Generated on Sun Jul 21 2013 13:37:24 by
1.8.4