neighboring25Direct.cc
Go to the documentation of this file.
00001 /* neighboring25Direct.cc
00002  */
00003 #include "osl/effect_util/neighboring25Direct.h"
00004 
00005 bool osl::effect_util::
00006 Neighboring25Direct::hasEffectFromTo(const NumEffectState& state,
00007                                      PtypeO ptypeo, Square from, 
00008                                      Square target, Offset offset)
00009 {
00010   target += offset; // 25 近傍全て試すなら手番による符合変換は不要
00011   return target.isOnBoard() && state.hasEffectIf(ptypeo, from, target);
00012 }
00013 
00014 bool osl::effect_util::
00015 Neighboring25Direct::hasEffectNaive(const NumEffectState& state,
00016                                     PtypeO ptypeo, Square from, 
00017                                     Square target)
00018 {
00019   const Ptype ptype = getPtype(ptypeo);
00020         
00021   if (! Ptype_Table.hasLongMove(ptype))
00022   {
00023     if (abs(from.y() - target.y()) > 4) // knight だけ4
00024       return false;
00025     if (abs(from.x() - target.x()) > 3)
00026       return false;
00027   }
00028   else if (ptype == LANCE)
00029   {
00030     if (abs(from.x() - target.x()) > 2)
00031       return false;
00032   }
00033         
00034   // naive な実装
00035   return hasEffectFromTo(state, ptypeo, from, target,newOffset(-2,-2))
00036     || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1,-2))
00037     || hasEffectFromTo(state, ptypeo, from, target,newOffset(-0,-2))
00038     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1,-2))
00039     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2,-2))
00040     || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2,-1))
00041     || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1,-1))
00042     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0,-1))
00043     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1,-1))
00044     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2,-1))
00045     || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2, 0))
00046     || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1, 0))
00047     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0, 0))
00048     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1, 0))
00049     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2, 0))
00050     || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2, 1))
00051     || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1, 1))
00052     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0, 1))
00053     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1, 1))
00054     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2, 1))
00055     || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2, 2))
00056     || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1, 2))
00057     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0, 2))
00058     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1, 2))
00059     || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2, 2));
00060         
00061 }
00062 
00063 /* ------------------------------------------------------------------------- */
00064 // ;;; Local Variables:
00065 // ;;; mode:c++
00066 // ;;; c-basic-offset:2
00067 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines