Go to the documentation of this file.00001
00002
00003 #include "osl/progress/effect5x3d.h"
00004 #include "osl/progress/effect5x3Table.h"
00005
00006 int osl::progress::
00007 Effect5x3d::makeProgress(Player defense, const NumEffectState& state,
00008 Square king)
00009 {
00010
00011 const Square center = Centering5x3::adjustCenter(king);
00012
00013 const int min_x = center.x() - 2;
00014 const int min_y = center.y() - 1;
00015
00016
00017 int sum_effect = 0;
00018
00019 for (int dx=0; dx<5; ++dx)
00020 {
00021 for (int dy=0; dy<3; ++dy)
00022 {
00023 const Square target(min_x+dx,min_y+dy);
00024 sum_effect += state.countEffect(defense, target) *
00025 Effect5x3_Table.getDefenseEffect(defense,king,dx,dy);
00026 }
00027 }
00028
00029 return sum_effect / 2;
00030 }
00031
00032 void osl::progress::
00033 Effect5x3d::update(const NumEffectState& new_state, Move )
00034 {
00035 const Square kb = new_state.kingSquare<BLACK>(), kw = new_state.kingSquare<WHITE>();
00036 BoardMask mb = new_state.changedEffects(BLACK), mw = new_state.changedEffects(WHITE);
00037
00038 if (mb.anyInRange(Board_Mask_Table5x3_Center.mask(kb)))
00039 progresses[BLACK]=makeProgress(BLACK,new_state,new_state.kingSquare<BLACK>());
00040 if (mw.anyInRange(Board_Mask_Table5x3_Center.mask(kw)))
00041 progresses[WHITE]=makeProgress(WHITE,new_state,new_state.kingSquare<WHITE>());
00042 }
00043
00044
00045
00046
00047
00048