Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
osl
progress
effect5x3.h
Go to the documentation of this file.
1
/* effect5x3.h
2
*/
3
#ifndef PROGRESS_EFFECT5X3_H
4
#define PROGRESS_EFFECT5X3_H
5
6
#include "
osl/progress/progress16.h
"
7
#include "
osl/state/numEffectState.h
"
8
#include "
osl/centering5x3.h
"
9
#include "
osl/misc/carray.h
"
10
#include <algorithm>
11
namespace
osl
12
{
13
namespace
progress
14
{
26
struct
Effect5x3
27
{
28
public
:
29
static
void
updateStand
(
int
& old_stand,
Move
last_move);
30
static
int
makeProgressAll
(
Player
defense,
const
NumEffectState& state,
31
Square
king);
32
static
int
makeProgressArea
(
Player
attack,
const
NumEffectState& state,
33
Square
king);
34
public
:
35
static
int
makeProgressStand
(
Player
attack,
const
NumEffectState& state);
44
static
int
makeProgress
(
Player
defense,
const
NumEffectState& state){
45
return
makeProgressAll
(defense,state,state.kingSquare(defense));
46
}
47
static
int
makeProgress
(
const
NumEffectState& state)
48
{
49
return
makeProgress
(
BLACK
, state) +
makeProgress
(
WHITE
, state);
50
}
54
static
const
Progress16
progress16
(
int
progress
)
55
{
56
assert(progress >= 0);
57
const
int
rank = progress / 8;
// 適当
58
return
Progress16
(
std::min
(rank, 15));
59
}
64
static
const
Progress16
progress16each
(
int
progress
)
65
{
66
assert(progress >= 0);
67
const
int
rank = progress / 8;
// 調整中
68
return
Progress16
(
std::min
(rank, 15));
69
}
70
protected
:
71
CArray<int,2>
progresses
,
stand_progresses
,
area_progresses
;
72
public
:
73
explicit
Effect5x3
(
const
NumEffectState& state);
74
void
changeTurn
() {}
75
int
progress
(
Player
p)
const
{
return
progresses
[p]; }
76
const
Progress16
progress16
()
const
77
{
78
return
progress16
(
progresses
[0] +
progresses
[1]);
79
}
80
const
Progress16
progress16
(
Player
p)
const
81
{
82
return
progress16each
(
progress
(p));
83
}
84
// 必要なもの
85
Effect5x3
expect
(
const
NumEffectState& state,
Move
move)
const
;
86
void
update
(
const
NumEffectState& new_state,
Move
last_move);
87
};
88
struct
Effect5x3WithBonus
:
public
Effect5x3
89
{
90
explicit
Effect5x3WithBonus
(
const
NumEffectState& state);
91
template
<Player Attack>
92
static
int
makeProgressAreaBonus
(
const
NumEffectState& state,
93
Square
king);
94
template
<Player Attack,
bool
AlwaysPromotable,
bool
AlwaysNotPromotable>
95
static
int
makeProgressAreaBonus
(
const
NumEffectState& state,
96
Square
king,
Square
center
);
97
const
Progress16
progress16bonus
(
Player
p)
const
98
{
99
return
progress16each
(
progress_bonuses
[p] +
100
stand_progresses
[p]);
101
}
102
void
update
(
const
NumEffectState& new_state,
Move
last_move);
103
Effect5x3WithBonus
expect
(
const
NumEffectState& state,
Move
move)
const
;
104
// Public for testing
105
int
countEffectPieces
(
const
NumEffectState &state,
Player
attack)
const
;
106
// p is defense player
107
const
PieceMask
effect5x3Mask
(
Player
p)
const
{
return
effect_mask
[p]; }
108
private
:
109
void
updateProgressBonuses
(
const
NumEffectState& state,
bool
black=
true
,
bool
white=
true
);
110
static
int
attackEffect3
(
const
NumEffectState& state,
Player
attack,
Square
target
);
111
template
<Player Defense>
112
static
PieceMask
makeEffectMask
(
const
NumEffectState& state);
113
void
updateStand
(
Player
pl,
Move
m) {
Effect5x3::updateStand
(
stand_progresses
[pl], m); }
114
115
CArray<int,2>
progress_bonuses
;
116
CArray<PieceMask, 2>
effect_mask
;
117
};
118
}
// namespace progress
119
}
// namespace osl
120
121
#endif
/* PROGRESS_EFFECT5X3_H */
122
// ;;; Local Variables:
123
// ;;; mode:c++
124
// ;;; c-basic-offset:2
125
// ;;; End:
Generated on Sun Jul 21 2013 13:37:24 by
1.8.4