00001
00002
00003 #include "osl/effect_util/neighboring25Direct.h"
00004
00005 bool osl::effect_util::
00006 Neighboring25Direct::hasEffectFromTo(const SimpleState& state,
00007 PtypeO ptypeo, Position from,
00008 Position target, Offset offset)
00009 {
00010 target += offset;
00011 return target.isOnBoard()
00012 && state.hasEffectFromTo(ptypeo, from, target);
00013 }
00014
00015 bool osl::effect_util::
00016 Neighboring25Direct::hasEffectNaive(const SimpleState& state,
00017 PtypeO ptypeo, Position from,
00018 Position target)
00019 {
00020 const Ptype ptype = getPtype(ptypeo);
00021
00022 if (! Ptype_Table.hasLongMove(ptype))
00023 {
00024 if (abs(from.y() - target.y()) > 4)
00025 return false;
00026 if (abs(from.x() - target.x()) > 3)
00027 return false;
00028 }
00029 else if (ptype == LANCE)
00030 {
00031 if (abs(from.x() - target.x()) > 2)
00032 return false;
00033 }
00034
00035
00036 return hasEffectFromTo(state, ptypeo, from, target,newOffset(-2,-2))
00037 || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1,-2))
00038 || hasEffectFromTo(state, ptypeo, from, target,newOffset(-0,-2))
00039 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1,-2))
00040 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2,-2))
00041 || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2,-1))
00042 || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1,-1))
00043 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0,-1))
00044 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1,-1))
00045 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2,-1))
00046 || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2, 0))
00047 || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1, 0))
00048 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0, 0))
00049 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1, 0))
00050 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2, 0))
00051 || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2, 1))
00052 || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1, 1))
00053 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0, 1))
00054 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1, 1))
00055 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2, 1))
00056 || hasEffectFromTo(state, ptypeo, from, target,newOffset(-2, 2))
00057 || hasEffectFromTo(state, ptypeo, from, target,newOffset(-1, 2))
00058 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 0, 2))
00059 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 1, 2))
00060 || hasEffectFromTo(state, ptypeo, from, target,newOffset( 2, 2));
00061
00062 }
00063
00064
00065
00066
00067
00068