All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
effect5x3d.cc
Go to the documentation of this file.
1 /* effect5x3d.cc
2  */
5 
7 Effect5x3d::makeProgress(Player defense, const NumEffectState& state,
8  Square king)
9 {
10 
11  const Square center = Centering5x3::adjustCenter(king);
12 
13  const int min_x = center.x() - 2;
14  const int min_y = center.y() - 1;
15 
16  // 利き
17  int sum_effect = 0;
18 
19  for (int dx=0; dx<5; ++dx)
20  {
21  for (int dy=0; dy<3; ++dy)
22  {
23  const Square target(min_x+dx,min_y+dy);
24  sum_effect += state.countEffect(defense, target) *
25  Effect5x3_Table.getDefenseEffect(defense,king,dx,dy);
26  }
27  }
28 
29  return sum_effect / 2;
30 }
31 
32 void osl::progress::
33 Effect5x3d::update(const NumEffectState& new_state, Move /*last_move*/)
34 {
35  const Square kb = new_state.kingSquare<BLACK>(), kw = new_state.kingSquare<WHITE>();
36  BoardMask mb = new_state.changedEffects(BLACK), mw = new_state.changedEffects(WHITE);
37 
38  if (mb.anyInRange(Board_Mask_Table5x3_Center.mask(kb)))
39  progresses[BLACK]=makeProgress(BLACK,new_state,new_state.kingSquare<BLACK>());
40  if (mw.anyInRange(Board_Mask_Table5x3_Center.mask(kw)))
41  progresses[WHITE]=makeProgress(WHITE,new_state,new_state.kingSquare<WHITE>());
42 }
43 
44 /* ------------------------------------------------------------------------- */
45 // ;;; Local Variables:
46 // ;;; mode:c++
47 // ;;; c-basic-offset:2
48 // ;;; End: