All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
neighboring25Direct.cc
Go to the documentation of this file.
1 /* neighboring25Direct.cc
2  */
4 
6 Neighboring25Direct::hasEffectFromTo(const NumEffectState& state,
7  PtypeO ptypeo, Square from,
8  Square target, Offset offset)
9 {
10  target += offset; // 25 近傍全て試すなら手番による符合変換は不要
11  return target.isOnBoard() && state.hasEffectIf(ptypeo, from, target);
12 }
13 
15 Neighboring25Direct::hasEffectNaive(const NumEffectState& state,
16  PtypeO ptypeo, Square from,
17  Square target)
18 {
19  const Ptype ptype = getPtype(ptypeo);
20 
21  if (! Ptype_Table.hasLongMove(ptype))
22  {
23  if (abs(from.y() - target.y()) > 4) // knight だけ4
24  return false;
25  if (abs(from.x() - target.x()) > 3)
26  return false;
27  }
28  else if (ptype == LANCE)
29  {
30  if (abs(from.x() - target.x()) > 2)
31  return false;
32  }
33 
34  // naive な実装
35  return hasEffectFromTo(state, ptypeo, from, target,newOffset(-2,-2))
36  || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1,-2))
37  || hasEffectFromTo(state, ptypeo, from, target,newOffset(-0,-2))
38  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1,-2))
39  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2,-2))
40  || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2,-1))
41  || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1,-1))
42  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0,-1))
43  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1,-1))
44  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2,-1))
45  || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2, 0))
46  || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1, 0))
47  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0, 0))
48  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1, 0))
49  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2, 0))
50  || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2, 1))
51  || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1, 1))
52  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0, 1))
53  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1, 1))
54  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2, 1))
55  || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2, 2))
56  || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1, 2))
57  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0, 2))
58  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1, 2))
59  || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2, 2));
60 
61 }
62 
63 /* ------------------------------------------------------------------------- */
64 // ;;; Local Variables:
65 // ;;; mode:c++
66 // ;;; c-basic-offset:2
67 // ;;; End: