effect5x3d.cc
Go to the documentation of this file.
/* effect5x3d.cc
*/
#include "osl/progress/effect5x3d.h"
#include "osl/progress/effect5x3Table.h"
#include "osl/bits/centering5x3.h"
int osl::progress::
Effect5x3d::makeProgress(Player defense, const NumEffectState& state,
Square king)
{
const Square center = Centering5x3::adjustCenter(king);
const int min_x = center.x() - 2;
const int min_y = center.y() - 1;
// 利き
int sum_effect = 0;
for (int dx=0; dx<5; ++dx)
{
for (int dy=0; dy<3; ++dy)
{
const Square target(min_x+dx,min_y+dy);
sum_effect += state.countEffect(defense, target) *
Effect5x3_Table.getDefenseEffect(defense,king,dx,dy);
}
}
return sum_effect / 2;
}
void osl::progress::
Effect5x3d::update(const NumEffectState& new_state, Move /*last_move*/)
{
const Square kb = new_state.kingSquare<BLACK>(), kw = new_state.kingSquare<WHITE>();
BoardMask mb = new_state.changedEffects(BLACK), mw = new_state.changedEffects(WHITE);
if (mb.anyInRange(Board_Mask_Table5x3_Center.mask(kb)))
progresses[BLACK]=makeProgress(BLACK,new_state,new_state.kingSquare<BLACK>());
if (mw.anyInRange(Board_Mask_Table5x3_Center.mask(kw)))
progresses[WHITE]=makeProgress(WHITE,new_state,new_state.kingSquare<WHITE>());
}
/* ------------------------------------------------------------------------- */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
centering5x3.h
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::NumEffectState::changedEffects
const BoardMask changedEffects(Player pl) const
Definition numEffectState.h:144
osl::NumEffectState::countEffect
int countEffect(Player player, Square target) const
利きの数を数える.
Definition numEffectState.h:266
osl::SimpleState::kingSquare
Square kingSquare() const
Definition simpleState.h:94
osl::Square
Definition basic_type.h:532
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
osl::Square::x
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
osl::container::BoardMask
11 x 12
Definition boardMask.h:21
osl::container::BoardMask::anyInRange
bool anyInRange(const BoardMask &mask) const
Definition boardMask.h:57
effect5x3Table.h
effect5x3d.h
osl::progress::Effect5x3_Table
Effect5x3Table Effect5x3_Table
Definition effect5x3Table.cc:13
osl::Player
Player
Definition basic_type.h:8
osl::WHITE
@ WHITE
Definition basic_type.h:10
osl::BLACK
@ BLACK
Definition basic_type.h:9
osl::Board_Mask_Table5x3_Center
const BoardMaskTable5x3Center Board_Mask_Table5x3_Center
Definition tables.cc:121
osl::Centering5x3::adjustCenter
static const Square adjustCenter(Square src)
Definition centering5x3.h:23
osl::progress::Effect5x3d::makeProgress
static int makeProgress(Player defense, const NumEffectState &state, Square king)
王の位置を指定したprogressの計算.
Definition effect5x3d.cc:8
osl::progress::Effect5x3d::progresses
CArray< int, 2 > progresses
Definition effect5x3d.h:58
osl::progress::Effect5x3d::update
void update(const NumEffectState &new_state, Move last_move)
Definition effect5x3d.cc:34