00001 /* pieceCost.h 00002 */ 00003 #ifndef _PIECECOST_H 00004 #define _PIECECOST_H 00005 00006 #include "osl/checkmate/checkMove.h" 00007 #include "osl/misc/carray.h" 00008 namespace osl 00009 { 00010 namespace checkmate 00011 { 00012 00016 struct PieceCost 00017 { 00018 static const CArray<signed char, PTYPE_SIZE> attack_sacrifice_cost; 00019 00021 template <class State> 00022 static void setAttackCost(Player attacker, const State&, 00023 CheckMove& move); 00025 template <class State> 00026 static void setDefenseCost(Player, const State&, CheckMove&) 00027 { 00028 } 00029 }; 00030 } // namespace checkmate 00031 } // namespace osl 00032 00033 template<typename State> inline 00034 void osl::checkmate::PieceCost:: 00035 setAttackCost(Player attacker, const State& state, CheckMove& move) 00036 { 00037 const Position from=move.move.from(); 00038 const Position to=move.move.to(); 00039 const Ptype capturePtype = move.move.capturePtype(); 00040 const Player defender = alt(attacker); 00041 // ʳǡǤȤϸ 00042 // 餯ƬˤʤɤǤڤåȤˤȤʤɤ 00043 if (capturePtype == PTYPE_EMPTY) 00044 { 00045 const int a = (state.countEffect(attacker,to) 00046 + (from.isPieceStand() ? 1 : 0)); 00047 int d = state.countEffect(defender,to); 00048 if (a <= d) 00049 { 00050 const Ptype ptype = move.move.ptype(); 00051 move.cost_proof = attack_sacrifice_cost[ptype] /* *8 */; 00052 if ((d >= 2) && (a == d)) // ɲȤ줿Ȥ 00053 move.cost_proof /= 2; 00054 } 00055 } 00056 } 00057 00058 #endif /* _PIECECOST_H */ 00059 // ;;; Local Variables: 00060 // ;;; mode:c++ 00061 // ;;; c-basic-offset:2 00062 // ;;; End: