説明を見る。00001
00002
00003 #include "osl/rating/group/king8Group.h"
00004 #include <sstream>
00005
00006 osl::rating::AttackKing8Group::AttackKing8Group()
00007 : Group("AttackKing8")
00008 {
00009 for (int attack=0; attack<3; ++attack) {
00010 for (int defense=0; defense<3; ++defense) {
00011 for (int s=PTYPE_PIECE_MIN; s<= PTYPE_MAX; ++s) {
00012 for (int t=PTYPE_PIECE_MIN; t<= PTYPE_MAX; ++t) {
00013 for (int p=0; p<8; ++p)
00014 push_back(new AttackKing8(static_cast<Ptype>(s), static_cast<Ptype>(t), true, attack, defense));
00015 for (int p=0; p<8; ++p)
00016 push_back(new AttackKing8(static_cast<Ptype>(s), static_cast<Ptype>(t), false, attack, defense));
00017 }
00018 for (int p=0; p<8; ++p)
00019 push_back(new AttackKing8(static_cast<Ptype>(s), PTYPE_EMPTY, true, attack, defense));
00020 }
00021 }
00022 }
00023 }
00024
00025 int osl::rating::AttackKing8Group::findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
00026 {
00027 const Ptype self = move.ptype();
00028 const Square position
00029 = Neighboring8Direct::findNearest(state, move.ptypeO(), move.to(),
00030 state.kingSquare(alt(state.turn())));
00031 if (position.isPieceStand() || position == move.from())
00032 return -1;
00033 if (! move.isDrop() && state.hasEffectByPiece(state.pieceOnBoard(move.from()), position))
00034 return -1;
00035 const Piece p = state.pieceAt(position);
00036 const Ptype target = p.ptype();
00037 const int base = CountEffect2::index(state, position, env)
00038 * (PTYPE_MAX+1 - PTYPE_PIECE_MIN) * ((PTYPE_MAX+1 - PTYPE_PIECE_MIN)*2 +1);
00039
00040 const int self_index = self - PTYPE_PIECE_MIN;
00041
00042 int index = base + self_index*((PTYPE_MAX+1 - PTYPE_PIECE_MIN)*2 +1);
00043 if (!isPiece(target)) {
00044 index += (PTYPE_MAX+1 - PTYPE_PIECE_MIN)*2;
00045 }
00046 else {
00047 index += (target - PTYPE_PIECE_MIN)*2 + (p.owner() != move.player());
00048 }
00049
00050 const int progress8 = env.progress.value()/2;
00051 return index*8 + progress8;
00052 }
00053
00054 osl::rating::DefenseKing8Group::DefenseKing8Group()
00055 : Group("DefenseKing8")
00056 {
00057 for (int danger=0; danger<=4; ++danger) {
00058 for (int s=PTYPE_PIECE_MIN; s<= PTYPE_MAX; ++s) {
00059 for (int p=0; p<8; ++p)
00060 push_back(new DefenseKing8(static_cast<Ptype>(s), true, danger));
00061 for (int p=0; p<8; ++p)
00062 push_back(new DefenseKing8(static_cast<Ptype>(s), false, danger));
00063 }
00064 }
00065 }
00066
00067 int osl::rating::DefenseKing8Group::findMatch(const NumEffectState& state, Move move, const RatingEnv& env) const
00068 {
00069 assert(env.attack_count_for_turn == DefenseKing8::count(state));
00070 const int self_index = (move.ptype() - PTYPE_PIECE_MIN)*2;
00071 int index;
00072 if (DefenseKing8::matchDrop(state, move))
00073 index = env.attack_count_for_turn*(PTYPE_MAX+1-PTYPE_PIECE_MIN)*2 + self_index;
00074 else if (DefenseKing8::matchMove(state, move))
00075 index = env.attack_count_for_turn*(PTYPE_MAX+1-PTYPE_PIECE_MIN)*2 + self_index + 1;
00076 else
00077 return -1;
00078 const int progress8 = env.progress.value()/2;
00079 return index*8 + progress8;
00080 }
00081
00082
00083
00084
00085
00086