00001 /* lance.h 00002 */ 00003 #ifndef OSL_CATEGORY_LANCE_H 00004 #define OSL_CATEGORY_LANCE_H 00005 00006 #include "osl/category/categoryTraits.h" 00007 #include "osl/category/categoryEnv.h" 00008 #include "osl/container/moveStack.h" 00009 #include "osl/container/moveVector.h" 00010 00011 namespace osl 00012 { 00013 namespace category 00014 { 00015 struct LanceAttackKing : public FixedProbabilityCategory 00016 { 00017 static FixedValueTable probTable; 00018 static const char *getName() { return "LanceAttackKing"; } 00019 static bool isInCategory(const CategoryEnv&env, Move move) 00020 { 00021 if (move.ptype() != LANCE || !move.isDrop()) 00022 return false; 00023 00024 const Player player = move.player(); 00025 const Position king = env.state->getKingPosition(alt(player)); 00026 00027 if (move.to().x() != king.x() || 00028 env.state->hasEffectBy(alt(player), move.to())) 00029 return false; 00030 00031 Position up = Board_Table.nextPosition(player, move.to(), U); 00032 Piece piece = env.state->getPieceAt(up); 00033 while (up.isOnBoard() && piece.isEmpty()) 00034 { 00035 up = Board_Table.nextPosition(player, up, U); 00036 piece = env.state->getPieceAt(up); 00037 } 00038 00039 if (!piece.isPiece() || piece.ptype() != PAWN) 00040 return false; 00041 00042 if (piece.owner() == alt(player) && 00043 ((player == BLACK && 00044 piece.position().y() == king.y() + 1) || 00045 (player == WHITE && 00046 piece.position().y() == king.y() - 1))) 00047 return true; 00048 00049 if (piece.owner() == player && 00050 abs(piece.position().y() - king.y()) <= 3) 00051 return true; 00052 00053 return false; 00054 } 00055 }; 00056 00057 // ι 00058 struct LanceSacrifice : public FixedProbabilityCategory 00059 { 00060 static FixedValueTable probTable; 00061 static const char *getName() { return "LanceSacrifice"; } 00062 static bool isInCategory(const CategoryEnv &env, Move move) 00063 { 00064 if (move.ptype() != LANCE || ! move.isDrop()) 00065 return false; 00066 00067 const Player player = move.player(); 00068 const Position king = env.state->getKingPosition(alt(player)); 00069 00070 return (env.progress32.value() > 15 && 00071 abs(move.to().x() - king.x()) <= 2 && 00072 abs(move.to().y() - king.y()) <= 2 && 00073 (move.to().x() == 3 || move.to().x() == 7) && 00074 (move.to().y() == 3 || move.to().y() == 7) && 00075 env.state->countEffect(alt(player), move.to()) > 1); 00076 } 00077 }; 00078 } // namespace category 00079 } // namespace osl 00080 00081 #endif /* OSL_CATEGORY_LANCE_H */ 00082 // ;;; Local Variables: 00083 // ;;; mode:c++ 00084 // ;;; c-basic-offset:2 00085 // ;;; End: