move_probability/feature.h
Go to the documentation of this file.
/* feature.h
*/
#ifndef OSL_MOVE_PROBABILITY_FEATURE_H
#define OSL_MOVE_PROBABILITY_FEATURE_H
#include "osl/move_probability/moveInfo.h"
#include "osl/move_probability/stateInfo.h"
#include "osl/additionalEffect.h"
#include "osl/effect_util/neighboring8Direct.h"
#include <string>
namespace osl
{
namespace move_probability
{
class Feature
{
std::string my_name;
int dim;
public:
Feature(std::string n, size_t d) : my_name(n), dim(d)
{
assert(dim > 0);
}
virtual ~Feature();
std::string name() const { return my_name; }
virtual double match(const StateInfo&, const MoveInfo&, int offset, const double *) const=0;
size_t dimension() const { return dim; }
static int classifyEffect9(const NumEffectState& state, Player player, Square to)
{
const int a = std::min(2, state.countEffect(player, to));
int d = std::min(2,state.countEffect(alt(player), to));
if (a>d)
d += AdditionalEffect::hasEffect(state, to, alt(player));
return a*3 + d;
}
};
class CheckFeature : public Feature
{
public:
enum { CHECK_CLASS = 4, RELATIVE_Y_CLASS = 3 };
CheckFeature()
: Feature("Check", CHECK_CLASS*PTYPE_SIZE*2*RELATIVE_Y_CLASS)
{
}
static int checkIndex(const MoveInfo& move)
{
if (move.open_check)
return 3;
return (move.see > 0) ? 0 : ((move.see == 0) ? 1 : 2);
}
static int sign(const NumEffectState& state, Move move,
Player player)
{
const Square king = state.kingSquare(alt(player));
int ry = (move.to().y() - king.y())*osl::sign(player);
if (ry == 0) return 0;
return ry > 0 ? 1 : -1;
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
if (! move.check && ! move.open_check)
return 0;
const Player player = move.player;
int index = sign(*state.state, move.move, player)+1;
index = (index*2 + move.move.isDrop())*PTYPE_SIZE
+ move.move.ptype();
index = index*CHECK_CLASS + checkIndex(move);
return w[offset+index];
}
};
class TakeBackFeature : public Feature
{
public:
TakeBackFeature() : Feature("TakeBack", 3)
{
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
if (! state.history->hasLastMove()
|| state.history->lastMove().to() != move.move.to())
return 0;
int match = 2;
if (move.see >= 0) {
--match;
if (state.history->hasLastMove(2)
&& state.history->lastMove(2).to() == move.move.to())
--match;
}
return w[offset + match];
}
};
class SeeFeature : public Feature
{
public:
enum { SeeClass = 23, YClass = 3, ProgressClass = 8 };
SeeFeature() : Feature("SeeFeature", SeeClass*(3+ProgressClass))
{
}
static int seeIndex(int see)
{
int index = see / 128;
if (see > 0) {
index = std::min(10, index);
index += 12;
} else if (see == 0) {
index += 11;
} else {
index += 10;
index = std::max(0, index);
}
return index;
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
const int see_index = seeIndex(move.see);
const Player player = move.player;
const Square to = move.move.to();
const int promote_index = to.canPromote(player)
? 1 : (to.canPromote(alt(player)) ? 2 : 0);
double sum = w[offset+see_index+promote_index*SeeClass];
int progress_index = YClass + state.progress8();
sum += w[offset+see_index+progress_index*SeeClass];
return sum;
}
};
class CapturePtype : public Feature
{
public:
CapturePtype() : Feature("CapturePtype", PTYPE_SIZE*PTYPE_SIZE*2*3)
{
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
const Ptype captured = move.move.capturePtype();
const Player player = move.player;
int index = (move.move.ptype())*PTYPE_SIZE + captured;
static_assert(PTYPE_EDGE == 1, "");
if (captured != PTYPE_EMPTY
&& captured == state.threatened[alt(player)].ptype())
++index;
if (move.see > 0)
index += PTYPE_SIZE*PTYPE_SIZE;
if (captured != PTYPE_EMPTY)
index += std::min(2, state.state->countPiecesOnStand(player, unpromote(captured)))
* (2*PTYPE_SIZE*PTYPE_SIZE);
return w[offset+index];
}
};
class ContinueCapture : public Feature
{
public:
ContinueCapture() : Feature("ContinueCapture", 1) {}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
if (move.move.capturePtype() == PTYPE_EMPTY
|| ! state.history->hasLastMove(2)
|| state.history->lastMove(2).to() != move.move.from())
return 0;
return w[offset];
}
};
class DropCaptured : public Feature
{
public:
DropCaptured() : Feature("DropCaptured", PTYPE_SIZE - PTYPE_BASIC_MIN) {}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
if (! move.move.isDrop()
|| ! state.history->hasLastMove(2)
|| ! state.history->lastMove(2).isNormal()
|| state.history->lastMove(2).capturePtype() != move.move.ptype())
return 0.0;
const size_t index = move.move.ptype() - PTYPE_BASIC_MIN;
assert(index < dimension());
return w[index + offset];
}
};
class SquareY : public Feature
{
public:
// PTYPE_SIZE, to [1,9], fromto [-3,3], drop|promote, progress8
enum {
DIM = 9*PTYPE_SIZE*16
};
SquareY() : Feature("SquareY", DIM)
{
}
static int fromTo(Square to, Square from) // [-3,3]
{
return std::max(-3, std::min(to.y() - from.y(), 3));
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
const Player P = info.player;
const Square to = move.to().squareForBlack(P);
size_t index = ((to.y()-1)*PTYPE_SIZE + move.ptype())*16;
assert(index+16 <= dimension());
const int from_to = move.isDrop() ? 0
: fromTo(to, move.from().squareForBlack(P));
double sum = w[offset + index + from_to + 3];
if (move.isDrop() || move.isPromotion())
sum += w[offset + index + 7];
sum += w[offset + index + state.progress8()+8];
return sum;
}
};
class SquareX : public Feature
{
public:
// PTYPE_SIZE, to [1,5], fromto [-3,3], drop|promote, progress8
SquareX() : Feature("SquareX", 5*PTYPE_SIZE*16)
{
}
static int fromTo(Square to, Square from) // [-3,3]
{
return std::max(-3, std::min(to.x() - from.x(), 3));
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
int to = move.to().x();
int from_to = move.isDrop() ? 0 : fromTo(move.to(), move.from());
if (to > 5) {
to = 10 - to;
from_to = -from_to;
}
size_t index = ((to-1)*PTYPE_SIZE + move.ptype())*16;
assert(index+16 <= dimension());
double sum = w[offset + index + from_to + 3];
if (move.isDrop() || move.isPromotion())
sum += w[offset + index + 7];
sum += w[offset + index + state.progress8()+8];
return sum;
}
};
class KingRelativeY : public Feature
{
public:
// PTYPE_SIZE, to [-8,8], fromto [-3,3], drop|promote, progress8
enum { ONE_DIM = 17*PTYPE_SIZE*16 };
KingRelativeY() : Feature("KingRelativeY", ONE_DIM*2)
{
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
const Player P = info.player;
const Ptype ptype = move.ptype();
const Square to = move.to().squareForBlack(P);
const Square my_king = state.state->kingSquare(P).squareForBlack(P);
const Square op_king = state.state->kingSquare(alt(P)).squareForBlack(P);
const int from_to = move.isDrop() ? 0
: SquareY::fromTo(to, move.from().squareForBlack(P));
size_t index = ((to.y()-my_king.y()+8)*PTYPE_SIZE + ptype)*16;
assert(index+16 <= ONE_DIM);
double sum = w[offset + index + from_to + 3];
if (move.isDrop() || move.isPromotion())
sum += w[offset + index + 7];
sum += w[offset + index + state.progress8()+8];
index = ((to.y()-op_king.y()+8)*PTYPE_SIZE + ptype)*16;
assert(index+16 <= ONE_DIM);
sum += w[offset + ONE_DIM + index + from_to + 3];
if (move.isDrop() || move.isPromotion())
sum += w[offset + ONE_DIM + index + 7];
sum += w[offset + ONE_DIM + index + state.progress8()+8];
return sum;
}
};
class KingRelativeX : public Feature
{
public:
// PTYPE_SIZE, to [0,8], fromto [-3,3], drop|promote, progress8
enum { ONE_DIM = 9*PTYPE_SIZE*16 };
KingRelativeX() : Feature("KingRelativeX", ONE_DIM*2)
{
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
const Player P = info.player;
const Ptype ptype = move.ptype();
const Square to = move.to();
const Square my_king = state.state->kingSquare(P);
const Square op_king = state.state->kingSquare(alt(P));
const int from_to = move.isDrop() ? 0
: SquareY::fromTo(to, move.from());
int dx = to.x() - my_king.x(), fx = from_to;
if (dx < 0) {
dx = -dx;
fx = -fx;
}
size_t index = (dx*PTYPE_SIZE + ptype)*16;
assert(index+16 <= ONE_DIM);
double sum = w[offset + index + fx + 3];
if (move.isDrop() || move.isPromotion())
sum += w[offset + index + 7];
sum += w[offset + index + state.progress8()+8];
dx = to.x() - op_king.x(), fx = from_to;
if (dx < 0) {
dx = -dx;
fx = -fx;
}
index = (dx*PTYPE_SIZE + ptype)*16;
assert(index+16 <= ONE_DIM);
sum += w[offset + ONE_DIM + index + fx + 3];
if (move.isDrop() || move.isPromotion())
sum += w[offset + ONE_DIM + index + 7];
sum += w[offset + ONE_DIM + index + state.progress8()+8];
return sum;
}
};
class FromEffect : public Feature
{
public:
FromEffect() : Feature("FromEffect", PTYPE_SIZE*PTYPE_SIZE*PTYPE_SIZE)
{
}
double match(const StateInfo& state_info, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
if (move.isDrop())
return 0;
const NumEffectState& state = *state_info.state;
const Ptype me = move.oldPtype();
const Ptype support = state.findCheapAttack(info.player, move.from()).ptype();
const Ptype attack = state.findCheapAttack(alt(info.player), move.from()).ptype();
const size_t index = (((me * PTYPE_SIZE) + support) * PTYPE_SIZE) + attack;
assert(index < dimension());
return w[index + offset];
}
};
class ToEffect : public Feature
{
public:
ToEffect() : Feature("ToEffect", PTYPE_SIZE*PTYPE_SIZE*PTYPE_SIZE*PTYPE_SIZE)
{
}
static const Piece find(const NumEffectState& state,
Square to, const PieceMask& remove,
Player player)
{
assert(to.isOnBoard());
PieceMask pieces = state.piecesOnBoard(player)
& state.effectSetAt(to);
pieces &= ~remove;
return state.selectCheapPiece(pieces);
}
static void supportAttack(const NumEffectState& state,
Square to,
const PieceMask& my_pin,
const PieceMask& op_pin,
Player turn,
std::pair<Ptype,Ptype>& out)
{
out.first = find(state, to, my_pin, turn).ptype(); // support
out.second = find(state, to, op_pin, alt(turn)).ptype(); // attack
}
static void supportAttack(const StateInfo& info, Square to, Move move,
std::pair<Ptype,Ptype>& out)
{
const Player turn = info.state->turn();
if (move.isDrop())
return supportAttack(*(info.state), to, info.pin[turn],
info.pin[alt(turn)], turn, out);
PieceMask my_pin = info.pin[turn];
my_pin.set(info.state->pieceAt(move.from()).number());
supportAttack(*(info.state), to, my_pin, info.pin[alt(turn)],
turn, out);
}
static size_t supportAttack(const StateInfo& info, Square to, Move move)
{
std::pair<Ptype,Ptype> pair;
supportAttack(info, to, move, pair);
return pair.first * PTYPE_SIZE + pair.second;
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
const Ptype me = move.ptype(), captured = move.capturePtype();
const size_t position_index = supportAttack(state, move.to(), move);
const size_t index = ((me * PTYPE_SIZE) + captured)
* PTYPE_SIZE * PTYPE_SIZE + position_index;
assert(index < dimension());
return w[index + offset];
}
};
class FromEffectLong : public Feature
{
public:
FromEffectLong() : Feature("FromEffectLong", PTYPE_SIZE*8*8)
{
}
double match(const StateInfo& state_info, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
if (move.isDrop())
return 0;
const NumEffectState& state = *state_info.state;
const Ptype ptype = move.oldPtype();
const CArray<bool,3> me = {{
state.longEffectAt<LANCE>(move.from(), info.player).any(),
state.longEffectAt<BISHOP>(move.from(), info.player).any(),
state.longEffectAt<ROOK>(move.from(), info.player).any(),
}};
const CArray<bool,3> op = {{
state.longEffectAt<LANCE>(move.from(), alt(info.player)).any(),
state.longEffectAt<BISHOP>(move.from(), alt(info.player)).any(),
state.longEffectAt<ROOK>(move.from(), alt(info.player)).any(),
}};
size_t index = ptype;
for (int i=0; i<3; ++i) {
index *= 2; index += me[i];
index *= 2; index += op[i];
}
assert(index < dimension());
return w[index + offset];
}
};
class ToEffectLong : public Feature
{
public:
ToEffectLong() : Feature("ToEffectLong", PTYPE_SIZE*8*8)
{
}
double match(const StateInfo& state_info, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
const NumEffectState& state = *state_info.state;
const Ptype ptype = move.oldPtype();
NumBitmapEffect effect=state.effectSetAt(move.to());
if (! move.isDrop())
effect.reset(state.pieceOnBoard(move.from()).number()+8);
const CArray<mask_t,3> pieces = {{
effect.selectLong<LANCE>() >> 8,
effect.selectLong<BISHOP>() >> 8,
effect.selectLong<ROOK>() >> 8
}};
size_t index = ptype;
for (int i=0; i<3; ++i) {
index *= 2;
index += (pieces[i] & state.piecesOnBoard(info.player).getMask(1)).any();
index *= 2;
index += (pieces[i] & state.piecesOnBoard(alt(info.player)).getMask(1)).any();
}
assert(index < dimension());
return w[index + offset];
}
};
class PatternCommon : public Feature
{
public:
enum {
SupportSize = PTYPE_SIZE,
AttackSize = PTYPE_SIZE, AttackBase = SupportSize, // 32
EffectSize = 9, EffectBase = AttackBase+AttackSize,
OpKingSize = 4, OpKingBase = EffectBase+EffectSize,
MyKingSize = 3, MyKingBase = OpKingBase+OpKingSize, // 48
PromotionSize = 2, PromotionBase = MyKingBase+MyKingSize,
PinOpenSize = 4, PinOpenBase = PromotionBase + PromotionSize,
LastToSize = 4, LastToBase = PinOpenBase + PinOpenSize,
LastEffectChangedSize = 6, LastEffectChangedBase = LastToBase + LastToSize,
SquareDim = LastEffectChangedBase + LastEffectChangedSize, // 64
PatternCacheSize = PTYPEO_SIZE*SquareDim,
OneDim = PTYPE_SIZE*PatternCacheSize,
};
PatternCommon(const std::string& name, int dim) : Feature(name, dim)
{
}
double addOne(const StateInfo& state, int offset,
const double *w, Square position) const
{
if (! position.isOnBoardRegion() || state.state->pieceAt(position).isEdge()) {
size_t basic = ptypeOIndex(PTYPEO_EDGE) *SquareDim;
return w[offset + basic];
}
const StateInfo::pattern_square_t& cache
= state.pattern_cache[position.index()];
double sum = 0.0;
for (size_t i=0; i<cache.size() && cache[i] >= 0; ++i)
sum += w[offset + cache[i]];
return sum;
}
static void updateCache(StateInfo& info);
private:
static void updateCacheOne(Square target, StateInfo& info);
};
template<bool TestPromotable>
class PatternBase : public PatternCommon
{
int dx, black_dy;
public:
enum {
PromotionSize = TestPromotable ? 3 : 1,
DIM = PromotionSize * OneDim,
};
PatternBase(int x, int y)
: PatternCommon(name(x,y), DIM), dx(x), black_dy(y)
{
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
const Ptype ptype = move.ptype();
int basic = ptype*PatternCacheSize;
int basic_from = (move.isPromotion() ? PTYPE_EDGE : PTYPE_EMPTY)
*PatternCacheSize;
const Square to = move.to();
if (TestPromotable && to.canPromote(info.player))
offset += OneDim;
else if (TestPromotable && to.canPromote(alt(info.player)))
offset += 2*OneDim;
int dy = info.player == BLACK ? black_dy : -black_dy;
Square target = to + Offset(dx, dy);
double sum = 0.0;
if (move.from() != target)
sum += addOne(state, offset+basic, w, target);
else // move from here
sum += addOne(state, offset+basic_from, w, target);
if (dx == 0)
return sum;
target = to + Offset(-dx, dy);
if (move.from() != target)
sum += addOne(state, offset+basic, w, target);
else
sum += addOne(state, offset+basic_from, w, target);
return sum;
}
static std::string name(int x, int y)
{
return std::string("Pattern")
+ (TestPromotable ? "P" : "")
+ "X" + (char)('2'+x) + "Y"+(char)('2'+y);
}
};
typedef PatternBase<false> Pattern;
typedef PatternBase<true> PatternPromotion;
class MoveFromOpposingSliders : public Feature
{
public:
MoveFromOpposingSliders() : Feature("MoveFromOpposingSliders", 36*PTYPE_SIZE)
{
}
static int longPtype(const NumEffectState& state, Square position, Player player)
{
const int offset = PtypeFuns<LANCE>::indexNum*32;
mask_t p = state.longEffectAt<LANCE>(position, player);
if (p.any())
return state.hasEffectAt(player, state.pieceOf(p.takeOneBit()+offset).square());
p = state.longEffectAt<BISHOP>(position, player);
if (p.any())
return 2 + state.hasEffectAt(player, state.pieceOf(p.takeOneBit()+offset).square());
p = state.longEffectAt<ROOK>(position, player);
assert(p.any());
return 4 + state.hasEffectAt(player, state.pieceOf(p.takeOneBit()+offset).square());
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
const Square from = move.move.from();
if (from.isPieceStand()
|| ! state.pinByOpposingSliders(state.state->pieceOnBoard(from)))
return 0.0;
const int me = longPtype(*state.state, from, move.player);
const int op = longPtype(*state.state, from, alt(move.player));
return w[offset + (me*6+op)*PTYPE_SIZE+move.move.ptype()];
}
};
class AttackFromOpposingSliders : public Feature
{
public:
AttackFromOpposingSliders() : Feature("AttackFromOpposingSliders", PTYPE_SIZE*PTYPE_SIZE*2)
{
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
const Piece attack = state.state->findCheapAttack(alt(info.player), move.to());
if (! state.pinByOpposingSliders(attack))
return 0.0;
if (state.state->countEffect(alt(info.player), move.to()) == 1)
offset += PTYPE_SIZE*PTYPE_SIZE;
double sum = w[offset + PTYPE_EMPTY*PTYPE_SIZE+attack.ptype()]
+ w[offset + move.ptype()*PTYPE_SIZE+PTYPE_EMPTY]
+ w[offset + move.ptype()*PTYPE_SIZE+attack.ptype()];
if (info.see < 0)
sum += w[offset + PTYPE_EMPTY*PTYPE_SIZE+PTYPE_EMPTY]*info.see/1024.0;
return sum;
}
};
class AttackToOpposingSliders : public Feature
{
public:
AttackToOpposingSliders() : Feature("AttackToOpposingSliders", PTYPE_SIZE*PTYPE_SIZE*2)
{
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
double sum = 0.0;
for (Piece piece: state.pin_by_opposing_sliders) {
if (! state.state->hasEffectIf(move.ptypeO(), move.to(),
piece.square()))
continue;
int base = (piece.owner() == info.player) ? PTYPE_SIZE*PTYPE_SIZE : 0;
sum += w[offset + base + PTYPE_EMPTY*PTYPE_SIZE+piece.ptype()]
+ w[offset + base + move.ptype()*PTYPE_SIZE+PTYPE_EMPTY]
+ w[offset + base + move.ptype()*PTYPE_SIZE+piece.ptype()];
if (info.see < 0)
sum += w[offset + base + PTYPE_EMPTY*PTYPE_SIZE+PTYPE_EMPTY]*info.see/1024.0;
}
return sum;
}
};
class PawnAttack : public Feature
{
public:
enum {
PTYPE2_DIM = PTYPE_SIZE*2*PTYPE_SIZE*2*2,
EFFECT_DIM = PTYPE_SIZE*2*8*9,
BasicSize = PTYPE2_DIM+EFFECT_DIM,
PawnSize = BasicSize*3,
DIM = PawnSize*2
};
PawnAttack() : Feature("PawnAttack", DIM)
{
}
std::pair<int,int> squareStatus(const NumEffectState& state, Player player, Square to, Square& front) const
{
int u = 0, uu = 0;
const int dy = (player == BLACK) ? -1 : 1;
Square position = to + Offset(0, dy);
front = position;
Piece piece = state.pieceAt(position);
if (piece.isPiece())
u = piece.ptype() + ((piece.owner() == player) ? PTYPE_SIZE : 0);
assert(! piece.isEdge()); // pawn move
piece = state.pieceAt(position + Offset(0, dy));
if (piece.isPiece())
uu = piece.ptype() + ((piece.owner() == player) ? PTYPE_SIZE : 0);
return std::make_pair(u, uu);
}
double matchPtype(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
const Player player = move.player;
const Square to = move.move.to();
Square front;
const std::pair<int,int> u = squareStatus(*state.state, player, to, front);
int promotion = 0;
if (front.canPromote(player))
promotion = 1;
else if (front.canPromote(alt(player)))
promotion = 2;
offset += BasicSize*promotion;
bool pawn_drop = move.move.isDrop();
const int index0 = (u.first*PTYPE_SIZE*2+u.second)*2 + pawn_drop;
double sum = w[offset + index0];
const int effect = classifyEffect9(*state.state, player, front);
const int index1 = u.first*8 + move.move.to().squareForBlack(player).y()-2;
sum += w[offset + index1*9+effect];
return sum;
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
if (move.move.ptype() == PAWN)
return matchPtype(state, move, offset, w);
if (move.move.ptype() == LANCE
&& state.state->canDropPawnTo(move.player, move.move.to().x()))
return matchPtype(state, move, offset+PawnSize, w);
return 0.0;
}
};
class BlockLong : public Feature
{
public:
enum {
AttackPtype = 8,
BasicAttack = AttackPtype*osl::PTYPEO_SIZE,
OptionSize = 8, // King8, HasSupport, Promotable, Shadowing,...
LongAttackSize = BasicAttack * OptionSize,
DIM = PTYPE_SIZE * 2 * LongAttackSize
};
BlockLong() : Feature("BlockLong", DIM)
{
}
static int longAttackIndex(osl::PtypeO ptypeo) // [0,7]?
{
const Ptype ptype = getPtype(ptypeo);
int index;
if (ptype == LANCE) index = 0;
else if (ptype == BISHOP) index = 1;
else if (ptype == ROOK) index = 2;
else {
assert(ptype == PROOK || ptype == PBISHOP);
index = 3;
}
if (getOwner(ptypeo) == WHITE) index += 4;
return index;
}
static double addPiece(const StateInfo& state, Piece piece,
Square to, const double *w, int offset)
{
assert(state.state->hasEffectByPiece(piece, to));
const Direction d
= Board_Table.getLongDirection<BLACK>(piece.square(), to);
const StateInfo::long_attack_t&
cache = state.long_attack_cache[piece.number()][longToShort(d)];
double sum = 0.0;
for (int index: cache) {
assert(index < LongAttackSize);
sum += w[index+offset];
}
return sum;
}
static int ptypeSupport(Ptype moved, bool has_support)
{
return (moved*2 + has_support) * LongAttackSize;
}
static double findAll(const StateInfo& state, Player P,
Square target, const double *w, int offset)
{
mask_t m = state.state->longEffectAt(target, P);
double sum = 0.0;
while (m.any()) {
const Piece piece = state.state->pieceOf
(m.takeOneBit() +PtypeFuns<LANCE>::indexNum*32);
sum += addPiece(state, piece, target, w, offset);
}
m = state.state->longEffectAt(target, alt(P));
while (m.any()) {
const Piece piece = state.state->pieceOf
(m.takeOneBit()+PtypeFuns<LANCE>::indexNum*32);
sum += addPiece(state, piece, target, w, offset);
}
return sum;
}
static double findAll(const StateInfo& state, Move move, const double *w, int offset=0)
{
const Player P = move.player();
Square target = move.to();
int a = state.state->countEffect(P, target);
offset += ptypeSupport(move.ptype(), a+move.isDrop()>1);
return findAll(state, P, target, w, offset);
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
return findAll(state, move.move, w, offset);
}
static void updateCache(StateInfo&);
private:
static void makeLongAttackOne(StateInfo& info,
Piece piece, Direction d);
};
class BlockLongFrom : public Feature
{
public:
enum {
DIM = BlockLong::LongAttackSize
};
BlockLongFrom() : Feature("BlockLongFrom", DIM)
{
}
static double findAll(const StateInfo& state, Move move, const double *w, int offset=0)
{
const Player P = move.player();
Square target = move.from();
return BlockLong::findAll(state, P, target, w, offset);
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
if (move.move.isDrop())
return 0;
return findAll(state, move.move, w, offset);
}
};
class LongRecapture : public Feature
{
public:
enum {
DIM = BlockLong::LongAttackSize * PTYPE_SIZE
};
LongRecapture() : Feature("LongRecapture", DIM)
{
}
double match(const StateInfo& info, const MoveInfo& move, int offset, const double *w) const
{
if (move.see >= 0)
return 0.0;
const NumEffectState& state = *info.state;
const Square to = move.move.to();
int a = state.countEffect(move.player, to)+move.move.isDrop()-1;
int d = state.countEffect(alt(move.player), to);
if (d == 1
|| (d == 2 && a > 0
&& state.hasEffectByPiece(state.kingPiece(alt(move.player)), to))) {
double sum = w[offset + (PTYPE_EMPTY)*BlockLong::LongAttackSize]
*move.see/1024.0;
offset += move.move.ptype() * BlockLong::LongAttackSize;
const Piece opponent = state.findCheapAttack(alt(move.player), to);
sum += BlockLong::findAll(info, move.player, opponent.square(), w, offset);
return sum;
}
return 0.0;
}
};
class AddEffectLong : public Feature
{
public:
enum {
DIM = PTYPE_SIZE*BlockLong::LongAttackSize
};
AddEffectLong() : Feature("AddEffectLong", DIM)
{
}
static double addOne(Direction dir, const StateInfo& state, const MoveInfo& move, int offset, const double *w)
{
Offset diff = Board_Table.getOffset(move.player, dir);
Square to = move.move.to() + diff;
if (isLong(dir)) {
while (state.state->pieceAt(to).isEmpty())
to += diff;
}
if (! state.state->pieceAt(to).isPiece())
return 0.0;
return BlockLong::findAll(state, move.player, to, w, offset);
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
offset += move.move.ptype()*BlockLong::LongAttackSize;
unsigned int directions = Ptype_Table.getMoveMask(move.move.ptype());
double sum = 0.0;
do {
Direction d = (Direction)(misc::BitOp::bsf(directions));
directions &= directions-1;
sum += addOne(d, state, move, offset, w);
} while (directions);
return sum;
}
};
class LanceAttack : public Feature
{
public:
enum {
PatternCacheSize = PatternCommon::PatternCacheSize,
DIM = PatternCacheSize*(8+4+4+1)
};
LanceAttack() : Feature("LanceAttack", DIM)
{
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
if (move.move.ptype() != LANCE
|| (! move.move.isDrop()
&& move.move.capturePtype() == PTYPE_EMPTY))
return 0;
const Offset up = Board_Table.getOffset(move.player, U);
Square target = move.move.to() + up;
while (state.state->pieceAt(target).isEmpty())
target += up;
if (state.state->pieceAt(target).isOnBoardByOwner(move.player)) {
target += up;
if (state.state->pieceAt(target).ptype() == LANCE) {
while (state.state->pieceAt(target).isEmpty())
target += up;
}
}
if (state.state->pieceAt(target).isEdge())
target -= up;
int y = move.move.to().y(), x = move.move.to().x();
if (move.player == WHITE)
y = 10-y;
y -= 2;
int dx1 = abs(state.state->kingSquare(move.player).x()-x);
int dx2 = abs(state.state->kingSquare(alt(move.player)).x()-x);
dx1 = std::min(dx1, 3);
dx2 = std::min(dx2, 3);
bool pawn = state.state->canDropPawnTo(alt(move.player), x);
assert(! state.state->pieceAt(target).isEdge());
const StateInfo::pattern_square_t& cache
= state.pattern_cache[target.index()];
double sum = 0.0;
for (size_t i=0; i<cache.size() && cache[i] >= 0; ++i) {
sum += w[offset + y*PatternCacheSize + cache[i]];
sum += w[offset + (8+dx1)*PatternCacheSize + cache[i]];
sum += w[offset + (12+dx1)*PatternCacheSize + cache[i]];
if (! pawn)
sum += w[offset + 16*PatternCacheSize + cache[i]];
}
return sum;
}
};
class BishopAttack : public Feature
{
public:
enum {
PatternCacheSize = PatternCommon::PatternCacheSize,
DIM = PatternCacheSize*2 // square:2
};
BishopAttack() : Feature("BishopAttack", DIM)
{
}
static double addSquare(Square target,
const StateInfo& info,
int offset, const double *w)
{
int type = 0;
const StateInfo::pattern_square_t& cache
= info.pattern_cache[target.index()];
double sum = 0.0;
for (size_t i=0; i<cache.size() && cache[i] >= 0; ++i) {
sum += w[offset + type + cache[i]];
}
return sum;
}
template <Direction D,Ptype Type>
static
double addOne(const StateInfo& info, Square to,
int offset, const double *w)
{
const NumEffectState& state = *info.state;
const Offset diff = DirectionPlayerTraits<D,BLACK>::offset();
Square target = to + diff;
double sum = 0.0;
if (state.pieceAt(target).isEdge())
return sum;
if (state.pieceAt(target).isPiece()
&& (state.pieceAt(target).ptype() != Type
|| state.pieceAt(target).owner() != state.turn())) {
; // almost included in direct pattern
} else {
while (state.pieceAt(target).isEmpty())
target += diff;
if (state.pieceAt(target).ptype() == Type
&& state.pieceAt(target).owner() == state.turn()) {
// extend additional effect by the same ptype
target += diff;
while (state.pieceAt(target).isEmpty())
target += diff;
}
if (state.pieceAt(target).isEdge())
target -= diff;
sum += addSquare(target, info, offset, w);
if (! state.pieceAt(target).isPiece())
return sum;
}
// shadowing
target += diff;
if (state.pieceAt(target).isEdge())
return sum;
while (state.pieceAt(target).isEmpty())
target += diff;
if (state.pieceAt(target).isEdge())
target -= diff;
sum += addSquare(target, info, offset+PatternCacheSize, w);
return sum;
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
if (unpromote(move.move.ptype()) != BISHOP)
return 0;
double sum = 0.0;
sum += addOne<UR,BISHOP>(state, move.move.to(), offset, w);
sum += addOne<UL,BISHOP>(state, move.move.to(), offset, w);
sum += addOne<DR,BISHOP>(state, move.move.to(), offset, w);
sum += addOne<DL,BISHOP>(state, move.move.to(), offset, w);
return sum;
}
};
class RookAttack : public Feature
{
public:
enum {
DirectionSize = BishopAttack::DIM,
DIM = DirectionSize*3
};
RookAttack() : Feature("RookAttack", DIM)
{
}
double match(const StateInfo& state, const MoveInfo& move, int offset, const double *w) const
{
if (unpromote(move.move.ptype()) != ROOK)
return 0;
const Square to = move.move.to();
double sum = 0.0;
sum += BishopAttack::addOne<R,ROOK>(state, to, offset, w);
sum += BishopAttack::addOne<L,ROOK>(state, to, offset, w);
const bool pawn_drop = state.state->canDropPawnTo(alt(move.player), to.x());
const int scale = pawn_drop ? 1 : 2;
sum += BishopAttack::addOne<U,ROOK>(state, to, offset+DirectionSize*scale, w);
sum += BishopAttack::addOne<D,ROOK>(state, to, offset+DirectionSize*scale, w);
return sum;
}
};
class BreakThreatmate : public Feature
{
public:
enum {
PatternCacheSize = PatternCommon::PatternCacheSize,
AddEffectSize = PTYPE_SIZE * PatternCacheSize,
OpenRoadSize = PTYPE_SIZE * PatternCacheSize, OpenRoadBase = AddEffectSize,
KingMoveSize = PatternCacheSize, KingMoveBase = OpenRoadBase + OpenRoadSize,
CaptureSize = PTYPE_SIZE*PTYPE_SIZE, CaptureBase = KingMoveBase + KingMoveSize,
AddEffect8Size = PTYPE_SIZE*PatternCacheSize, AddEffect8Base = CaptureBase + CaptureSize,
OtherMoveSize = 1, OtherMoveBase = AddEffect8Base + AddEffect8Size, // should be penalized
DIM = OtherMoveBase + OtherMoveSize
};
BreakThreatmate() : Feature("BreakThreatmate", DIM)
{
}
static bool isKingMove(Move move)
{
return move.ptype() == KING;
}
static bool isOpeningKingRoad(Move move, Square king)
{
return ! move.isDrop()
&& move.from().isNeighboring8(king);
}
static bool isDefendingThreatmate(Move move, Move threatmate,
const NumEffectState& state)
{
if (move.to() == threatmate.to()
|| state.hasEffectIf(move.ptypeO(), move.to(),
threatmate.to()))
return true;
if (threatmate.isDrop())
return false;
Offset32 offset32=Offset32(threatmate.from(),move.to());
EffectContent effect=Ptype_Table.getEffect(move.ptypeO(),offset32);
if (! effect.hasEffect())
return false;
if (effect.offset() == threatmate.to()-threatmate.from())
return state.isEmptyBetween(threatmate.from(), move.to());
return false;
}
static bool isDefendingKing8(Move move, Square king,
const NumEffectState& state)
{
if (Neighboring8Direct::hasEffect
(state, move.ptypeO(), move.to(), king))
return true;
mask_t m = state.longEffectAt(move.to(), alt(state.turn()));
while (m.any()) {
const Piece piece = state.pieceOf
(m.takeOneBit() +PtypeFuns<LANCE>::indexNum*32);
if (Neighboring8Direct::hasEffect
(state, piece.ptypeO(), piece.square(), king))
return true;
}
return false;
}
double match(const StateInfo& info, const MoveInfo& move, int offset, const double *w) const
{
if (! info.threatmate_move.isNormal())
return 0;
const NumEffectState& state = *info.state;
const StateInfo::pattern_square_t& cache
= info.pattern_cache[move.move.to().index()];
const int PatternAny = ptypeOIndex(PTYPEO_EDGE)*PatternCommon::SquareDim;
double sum = 0.0;
if (isKingMove(move.move)) {
// king move
sum += w[offset + KingMoveBase + PatternAny];
for (size_t i=0; i<cache.size() && cache[i] >= 0; ++i) {
sum += w[offset + KingMoveBase + cache[i]];
}
} else {
const Square king = state.kingSquare(move.player);
if (isOpeningKingRoad(move.move, king)) {
// open king road
int base = OpenRoadBase + move.move.ptype()*PatternCacheSize;
sum += w[offset + base + PatternAny];
for (size_t i=0; i<cache.size() && cache[i] >= 0; ++i) {
sum += w[offset + base + cache[i]];
}
}
if (isDefendingThreatmate(move.move, info.threatmate_move,
state)) {
// add effect to threatmate-move-at
int base = move.move.ptype()*PatternCacheSize;
sum += w[offset + base + PatternAny];
for (size_t i=0; i<cache.size() && cache[i] >= 0; ++i) {
sum += w[offset + base + cache[i]];
}
} else if (isDefendingKing8(move.move, king, state)) {
// add effect to king8
int base = move.move.ptype()*PatternCacheSize
+ AddEffect8Base;
sum += w[offset + base + PatternAny];
for (size_t i=0; i<cache.size() && cache[i] >= 0; ++i) {
sum += w[offset + base + cache[i]];
}
}
const Piece captured = state.pieceOnBoard(move.move.to());
// capture
if (captured.isPiece()) {
if (Neighboring8Direct::hasEffect
(state, captured.ptypeO(), captured.square(), king)) {
sum += w[offset + CaptureBase
+ captured.ptype()*PTYPE_SIZE+move.move.ptype()];
sum += w[offset + CaptureBase
+ captured.ptype()*PTYPE_SIZE];
}
else {
sum += w[offset + CaptureBase + captured.ptype()*PTYPE_SIZE
+ PTYPE_EDGE];
}
}
}
if (sum == 0.0)
sum += w[offset + OtherMoveBase];
return sum;
}
};
class SendOff : public Feature
{
public:
enum {
DIM = PTYPE_SIZE,
};
SendOff() : Feature("SendOff", DIM)
{
}
double match(const StateInfo& info, const MoveInfo& move, int offset, const double *w) const
{
if (! info.sendoffs.isMember(move.move.to()))
return 0;
return w[offset + move.move.ptype()];
}
};
class LureDefender : public Feature
{
public:
enum {
ATTACK_DIM = PTYPE_SIZE*PTYPE_SIZE*PTYPE_SIZE,
DIM = ATTACK_DIM*3,
};
LureDefender() : Feature("LureDefender", DIM)
{
}
static double match(const NumEffectState& state, Move move, int see,
const StateInfo::pinned_gs_t& pinned_list,
int offset, const double *w)
{
const Square to = move.to(), king = state.kingSquare(alt(state.turn()));
const Offset up = Board_Table.getOffset(state.turn(), U);
const int basic_a = move.ptype() * PTYPE_SIZE*PTYPE_SIZE;
double sum = 0.0;
for (PinnedGeneral defense: pinned_list) {
if (to != defense.attack)
continue;
assert(defense.general.owner() != move.player());
assert(defense.covered.owner() != move.player());
if (defense.general.square() == move.to()+up)
offset += ATTACK_DIM;
else if (state.hasEffectIf(move.ptypeO(), move.to(), defense.general.square()))
offset += ATTACK_DIM*2;
int a = basic_a;
if (defense.covered.square().canPromote(state.turn())
&& canPromote(move.ptype()))
a = promote(move.ptype()) * PTYPE_SIZE*PTYPE_SIZE;
const int b = defense.general.ptype() * PTYPE_SIZE;
const int c = defense.covered.ptype();
sum += w[offset];
if (see < 0)
sum += w[offset+1] * see/1024.0;
sum += w[offset + a];
sum += w[offset + b];
sum += w[offset + c];
sum += w[offset + a + b];
sum += w[offset + a + c];
sum += w[offset + b + c];
if (defense.covered.square().canPromote(state.turn())) {
sum += w[offset + a + PTYPE_EDGE];
sum += w[offset + b + PTYPE_EDGE];
}
if (defense.covered.square().isNeighboring8(king)) {
sum += w[offset + a + KING];
sum += w[offset + b + KING];
}
sum += w[offset + a + b + c];
break;
}
return sum;
}
double match(const StateInfo& info, const MoveInfo& move, int offset, const double *w) const
{
return match(*info.state, move.move, move.see,
info.exchange_pins[alt(move.player)], offset, w);
}
};
class CheckmateIfCapture : public Feature
{
public:
enum {
DIM = PTYPE_SIZE*PTYPE_SIZE,
};
CheckmateIfCapture() : Feature("CheckmateIfCapture", DIM)
{
}
double match(const StateInfo& info, const MoveInfo& move, int offset, const double *w) const
{
if (info.state->inCheck() || move.see > -256)
return 0;
const Square king = info.state->kingSquare(alt(move.player));
if (move.move.capturePtype() != PTYPE_EMPTY
&& ! info.state->hasPieceOnStand<GOLD>(move.player)
&& ! info.state->hasPieceOnStand<SILVER>(move.player)
&& ! info.move_candidate_exists[alt(move.player)])
return 0;
if (! Neighboring8Direct::hasEffect
(*info.state, move.move.ptypeO(), move.move.to(), king))
return 0;
if (hasSafeCapture(info.copy, move.move))
return 0;
int ptype_index = move.move.ptype()*PTYPE_SIZE;
int capture_index = move.move.capturePtype();
double sum = 0.0;
sum += w[offset + ptype_index + capture_index];
sum += w[offset + capture_index];
sum += w[offset + ptype_index + PTYPE_EDGE];
sum += w[offset + PTYPE_EDGE];
return sum;
}
static bool hasSafeCapture(NumEffectState& state, Move);
};
class AttackKing8Long : public Feature
{
public:
enum {
DIM = PTYPE_SIZE*PTYPE_SIZE,
};
AttackKing8Long() : Feature("AttackKing8Long", DIM)
{
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
double sum = 0.0;
for (Piece piece: state.king8_long_pieces) {
if (! state.state->hasEffectIf(move.ptypeO(), move.to(),
piece.square()))
continue;
sum += w[offset + PTYPE_EMPTY*PTYPE_SIZE+piece.ptype()]
+ w[offset + move.ptype()*PTYPE_SIZE+PTYPE_EMPTY]
+ w[offset + move.ptype()*PTYPE_SIZE+piece.ptype()];
if (state.pin_by_opposing_sliders.isMember(piece)
&& info.see < 0)
sum += w[offset + PTYPE_EMPTY*PTYPE_SIZE+PTYPE_EDGE]*info.see/1024.0;
}
return sum;
}
};
class OpposingPawn : public Feature
{
public:
enum {
DIM = /*king-x*/9 * /* stand-pawn */ 3 * /* others */ 2,
};
OpposingPawn() : Feature("OpposingPawn", DIM)
{
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
if (move.ptype() != PAWN)
return 0.0;
const Square front = move.to() + Board_Table.getOffset(info.player, U);
if (state.state->pieceAt(front).ptype() != PAWN)
return 0.0;
int king_x = abs(state.state->kingSquare(alt(info.player)).x() - front.x());
int stand_pawn = state.state->countPiecesOnStand<PAWN>(info.player);
if (move.isDrop())
--stand_pawn;
stand_pawn = std::min(2, stand_pawn);
bool has_other = state.state->hasPieceOnStand<LANCE>(info.player)
|| state.state->hasPieceOnStand<KNIGHT>(info.player)
|| state.state->hasPieceOnStand<SILVER>(info.player)
|| state.state->hasPieceOnStand<GOLD>(info.player)
|| state.state->hasPieceOnStand<ROOK>(info.player)
|| state.state->hasPieceOnStand<BISHOP>(info.player);
int index = (king_x * 3 + stand_pawn) * 2 + has_other;
return w[offset + index];
}
};
class DropAfterOpposingPawn : public Feature
{
public:
enum {
DIM = /*king-x*/9 * /* stand-pawn */ 3 * /* others */ 2 * /* capturepawn */ 2,
};
DropAfterOpposingPawn() : Feature("DropAfterOpposingPawn", DIM)
{
}
double match(const StateInfo& state, const MoveInfo& info, int offset, const double *w) const
{
const Move move = info.move;
if (move.ptype() != PAWN || ! move.isDrop() || ! state.history->hasLastMove())
return 0.0;
int to_x = move.to().x();
const Move last_move = state.history->lastMove();
if (! last_move.isNormal() || last_move.isDrop()
|| last_move.to().x() != to_x
|| last_move.from().x() != to_x)
return 0.0;
const Square front = move.to()+Board_Table.getOffset(info.player, U);
if (! front.canPromote(info.player))
return 0.0;
int king_x = abs(state.state->kingSquare(alt(info.player)).x() - to_x);
int stand_pawn = std::min(2, state.state->countPiecesOnStand<PAWN>(info.player)-1);
bool has_other = state.state->hasPieceOnStand<LANCE>(info.player)
|| state.state->hasPieceOnStand<KNIGHT>(info.player)
|| state.state->hasPieceOnStand<SILVER>(info.player)
|| state.state->hasPieceOnStand<GOLD>(info.player)
|| state.state->hasPieceOnStand<ROOK>(info.player)
|| state.state->hasPieceOnStand<BISHOP>(info.player);
bool follow_pawn_capture = last_move.capturePtype() == PAWN;
int index = ((king_x * 3 + stand_pawn) * 2 + has_other) * 2 + follow_pawn_capture;
return w[offset + index];
}
};
class CoverPawn : public Feature
{
public:
enum {
DIM = 9 * 2 * PTYPE_SIZE * PTYPE_SIZE
};
CoverPawn() : Feature("CoverPawn", DIM)
{
}
double match(const StateInfo& si, const MoveInfo& mi, int offset, const double *w) const
{
if (! si.history->hasLastMove() || si.state->inCheck()
|| mi.move.isCaptureOrPromotion())
return 0.0;
const Move last_move = si.history->lastMove();
if (last_move.ptype() != PAWN)
return 0.0;
const Offset diff = Board_Table.getOffset(mi.player, U);
const Square front = last_move.to()-diff, front2 = front-diff;
if (si.state->pieceOnBoard(front).ptype() != PAWN // must be turn's pawn
|| si.state->pieceAt(front2).isOnBoardByOwner(alt(mi.player)))
return 0.0;
const bool cover = si.state->hasEffectIf
(mi.move.ptypeO(), mi.move.to(), front);
const Ptype moved = cover ? mi.move.ptype() : PTYPE_EDGE,
threatened = si.state->pieceAt(front2).ptype();
const int a = std::min(2,si.state->countEffect(alt(mi.player), front) - 1);
assert(a >= 0);
const int b = std::min(2,si.state->countEffect(mi.player, front));
const int ptype_index = moved*PTYPE_SIZE+threatened;
const bool has_pawn = si.state->hasPieceOnStand(alt(mi.player),PAWN);
const int pawn_index = PTYPE_SIZE*PTYPE_SIZE;
const int effect_index = (a*3+b)*2*PTYPE_SIZE*PTYPE_SIZE
+ (has_pawn ? pawn_index : 0);
assert(effect_index >= 0);
return w[offset + threatened]
+ w[offset + ptype_index]
+ w[offset + effect_index + ptype_index];
}
};
class SacrificeAttack : public Feature
{
public:
enum {
StandCount = 64,
DIM = StandCount * PTYPE_SIZE * 2
};
SacrificeAttack() : Feature("SacrificeAttack", DIM)
{
}
double match(const StateInfo& si, const MoveInfo& mi, int offset, const double *w) const
{
const Square king = si.state->kingSquare(alt(mi.player));
if (mi.see >= 0
|| (! Neighboring8Direct::hasEffect
(*si.state, mi.move.ptypeO(), mi.move.to(), king)))
return 0.0;
assert(PieceStand::order[6] == PAWN);
int stand = mi.standIndex(*si.state);
int index = (stand * PTYPE_SIZE + mi.move.ptype()) * 2;
double sum = w[offset + index];
if (si.history->hasLastMove(2)) {
Move my_last_move = si.history->lastMove(2);
if (my_last_move.isNormal()
&& Neighboring8Direct::hasEffect
(*si.state, my_last_move.ptypeO(), my_last_move.to(), king))
sum += w[offset + index + 1];
}
return sum;
}
};
class King5x5Ptype : public Feature
{
public:
enum {
ONE_DIM = 25 * 4 * PTYPE_SIZE * PTYPE_SIZE,
DIM = 2 * ONE_DIM,
};
King5x5Ptype() : Feature("King5x5Ptype", DIM)
{
}
static double addOne(Player king, Square center, const StateInfo& si, const MoveInfo& mi, int offset, const double *w)
{
const Square to = mi.move.to();
int dx = center.x() - to.x();
const int dy = center.y() - to.y();
if (abs(dx) >= 3 || abs(dy) >= 3)
return 0.0;
if ((king == BLACK && center.x() > 5)
|| (king == WHITE && center.x() >= 5))
dx = -dx;
int sq_index = (dx+2)*5 + dy+2;
bool a = mi.move.isDrop() ? si.state->hasEffectAt(mi.player, to)
: si.state->countEffect(mi.player,to) >= 2;
bool d = si.state->hasEffectAt(alt(mi.player), to);
int index = (sq_index*4 + a*2+d) * PTYPE_SIZE*PTYPE_SIZE
+ mi.move.capturePtype()*PTYPE_SIZE + mi.move.ptype();
return w[offset + index];
}
double match(const StateInfo& si, const MoveInfo& mi, int offset, const double *w) const
{
return
addOne(mi.player, si.state->kingSquare(mi.player), si, mi, offset, w)
+ addOne(alt(mi.player), si.state->kingSquare(alt(mi.player)), si, mi,
offset+ONE_DIM, w);
}
};
class KingBlockade : public Feature
{
public:
enum {
StandCount = SacrificeAttack::StandCount,
BlockLastOne = 0, BlockFront = 1,
BlockSideWide = 2, BlockSideOther = 3, BlockBack = 4,
DIM = 5 * StandCount
};
KingBlockade() : Feature("KingBlockade", DIM)
{
}
static bool blockAll(const King8Info& ki, Square king, Move move,
const NumEffectState& state,
const CArray<Direction,3>& directions)
{
int liberty = 0;
for (Direction d: directions) {
if ((ki.liberty() & (1<<d)) == 0)
continue;
++liberty;
const Square sq = king + Board_Table.getOffset(alt(state.turn()), d);
if (! state.hasEffectIf(move.ptypeO(), move.to(), sq))
return false;
}
return liberty > 0;
}
double match(const StateInfo& si, const MoveInfo& mi, int offset, const double *w) const
{
const NumEffectState& state = *si.state;
const King8Info ki = si.king8Info(alt(mi.player));
const Square king = state.kingSquare(alt(mi.player));
if (ki.libertyCount() == 0
|| (! Neighboring8Direct::hasEffect
(state, mi.move.ptypeO(), mi.move.to(), king)))
return 0.0;
int stand = mi.standIndex(state);
offset += stand*5;
double sum = 0.0;
if (ki.libertyCount() == 1) {
const Square sq = king
+ Board_Table.getOffset(alt(mi.player),
(Direction)misc::BitOp::bsf(ki.liberty()));
if (! state.hasEffectIf(mi.move.ptypeO(), mi.move.to(), sq))
return 0.0;
sum += w[offset+BlockLastOne];
// fall through
}
const CArray<Direction,3> front3 = {{ UL, U, UR }};
if (blockAll(ki, king, mi.move, state, front3))
sum += w[offset+BlockFront];
const CArray<Direction,3> left3 = {{ UL, L, DL }};
if (blockAll(ki, king, mi.move, state, left3)) {
const bool wide = (mi.player== WHITE && king.x() < 5)
|| (mi.player== BLACK && king.x() > 5);
sum += w[offset+(wide ? BlockSideWide : BlockSideOther)];
}
const CArray<Direction,3> right3 = {{ UR, R, DR }};
if (blockAll(ki, king, mi.move, state, right3)) {
const bool wide = (mi.player== BLACK && king.x() < 5)
|| (mi.player== WHITE && king.x() > 5);
sum += w[offset+ (wide ? BlockSideWide : BlockSideOther)];
}
const CArray<Direction,3> back3 = {{ DL, D, DR }};
if (blockAll(ki, king, mi.move, state, back3))
sum += w[offset+BlockBack];
return sum;
}
};
class CoverFork : public Feature
{
public:
enum {
DIM = PTYPE_SIZE * PTYPE_SIZE * PTYPE_SIZE
};
CoverFork() : Feature("CoverFork", DIM)
{
}
static bool defending(const NumEffectState& state, Move move, Square target)
{
if (state.countEffect(alt(state.turn()), target) > 1)
return false;
if (state.hasEffectIf(move.ptypeO(), move.to(), target))
return true;
Piece attacking = state.findCheapAttack(alt(state.turn()), target);
Offset o = Board_Table.getShortOffsetNotKnight(Offset32(move.to(), target));
if (o.zero()
|| ! Board_Table.isBetween(move.to(), attacking.square(), target))
return false;
return state.countEffect(state.turn(), move.to()) >= (1-move.isDrop());
}
double match(const StateInfo& si, const MoveInfo& mi, int offset, const double *w) const
{
const NumEffectState& state = *si.state;
PieceMask attacked = state.piecesOnBoard(mi.player)
& state.effectedMask(alt(mi.player))
& ~(state.effectedMask(mi.player));
attacked.clearBit<PAWN>();
offset += mi.move.ptype()*PTYPE_SIZE*PTYPE_SIZE;
double sum = 0.0;
while (attacked.any()) {
Piece a = state.pieceOf(attacked.takeOneBit());
if (! defending(state, mi.move, a.square()))
continue;
int index_a = a.ptype()*PTYPE_SIZE;
PieceMask copy = attacked;
while (copy.any()) {
Piece b = state.pieceOf(copy.takeOneBit());
if (! defending(state, mi.move, b.square()))
continue;
sum += w[offset];
sum += w[offset+index_a];
sum += w[offset+b.ptype()];
sum += w[offset+index_a+b.ptype()];
}
}
return sum;
}
};
class ThreatmateByCapture : public Feature
{
public:
enum {
DIM = PTYPE_SIZE * PTYPE_SIZE
};
ThreatmateByCapture() : Feature("ThreatmateByCapture", DIM)
{
}
double match(const StateInfo& si, const MoveInfo& mi, int offset, const double *w) const
{
const Move move = mi.move;
const Ptype captured = move.capturePtype();
if (captured == PTYPE_EMPTY
|| (si.possible_threatmate_ptype
& 1<<(captured-PTYPE_BASIC_MIN)) == 0)
return 0.0;
double sum = 0.0;
sum += w[offset];
if (mi.see < 0)
sum += w[offset+1] * mi.see/1024.0;
sum += w[offset+captured];
sum += w[offset+move.ptype()*PTYPE_SIZE];
sum += w[offset+move.ptype()*PTYPE_SIZE+captured];
return sum;
}
};
class PromotionBySacrifice : public Feature
{
public:
enum {
DIM = 2*PTYPE_SIZE * PTYPE_SIZE
};
PromotionBySacrifice() : Feature("PromotionBySacrifice", DIM)
{
}
double match(const StateInfo& si, const MoveInfo& mi, int offset, const double *w) const
{
const Move move = mi.move;
if (mi.see >= 0 || move.isDrop()
|| si.state->inCheck()
|| si.threatmate_move.isNormal())
return 0.0;
const NumEffectState& state = *si.state;
mask_t m = state.longEffectAt(move.from(), state.turn());
m &= ~mask_t::makeDirect(PtypeFuns<LANCE>::indexMask);
double sum = 0.0;
while (m.any()) {
const Piece piece = state.pieceOf
(m.takeOneBit() +PtypeFuns<LANCE>::indexNum*32);
assert(piece.ptype() != LANCE);
if (piece.isPromoted()
|| piece.square().canPromote(mi.player))
continue;
Offset o = Board_Table.getShortOffsetNotKnight(Offset32(move.from(), piece.square()));
assert(! o.zero());
bool can_promote = false;
Square to = move.from()+o;
if (to == move.to())
continue;
while (state[to].isEmpty()) {
if (to.canPromote(mi.player)
&& ! state.hasEffectAt(alt(mi.player), to))
can_promote = true;
to += o;
}
assert(state[to] != piece);
int index = 0;
if (piece.ptype() == ROOK)
index += PTYPE_SIZE*PTYPE_SIZE;
index += move.ptype()*PTYPE_SIZE;
if (to.canPromote(mi.player)
&& state[to].isOnBoardByOwner(alt(mi.player))
&& ! state.hasEffectAt(alt(mi.player), to)) {
sum += w[offset];
sum += w[offset+1]*mi.see/1024.0;
if (mi.check)
sum += w[offset+2];
if (state.hasEffectAt(alt(mi.player), piece.square())) {
sum += w[offset+3];
if (mi.check)
sum += w[offset+4];
}
if (state.hasEffectIf(piece.ptypeO(), to,
state.kingSquare(alt(mi.player))))
sum += w[offset+5];
sum += w[offset + index + state[to].ptype()];
}
else if (can_promote) {
sum += w[offset];
sum += w[offset+1]*mi.see/1024.0;
if (mi.check)
sum += w[offset+2];
if (state.hasEffectAt(alt(mi.player), piece.square())) {
sum += w[offset+3];
if (mi.check)
sum += w[offset+4];
}
sum += w[offset + index];
}
}
return sum;
}
};
class EscapeThreatened : public Feature
{
public:
enum {
DIM =(2*PTYPE_SIZE * PTYPE_SIZE) * 3 * PTYPE_SIZE
};
EscapeThreatened() : Feature("EscapeThreatened", DIM)
{
}
double match(const StateInfo& si, const MoveInfo& mi, int offset, const double *w) const
{
const NumEffectState& state = *si.state;
const Move move = mi.move;
const Piece target = si.threatened[mi.player];
if (mi.see > 0 || mi.check || mi.open_check
|| ! move.isNormal()
|| ! target.isPiece() || state.inCheck()
|| si.threatmate_move.isNormal()
|| Neighboring8Direct::hasEffect
(state, move.ptypeO(), move.to(), state.kingSquare(alt(mi.player))))
return 0.0;
const int t0 = target.ptype()*PTYPE_SIZE*2*PTYPE_SIZE*3;
const int t1 = t0 + state.findCheapAttack(alt(mi.player), target.square()).ptype()*2*PTYPE_SIZE*3;
const int t2 = t1 + state.hasEffectAt(mi.player, target.square())*PTYPE_SIZE*3;
double sum = 0.0;
if (! move.isDrop() && state[move.from()] == target) {
sum += w[offset + t0];
sum += w[offset + t1];
sum += w[offset + t2];
return sum;
}
if (state.hasEffectIf(move.ptypeO(), move.to(),
target.square())) {
if (move.isDrop()
|| ! state.hasEffectIf(move.oldPtypeO(), move.from(),
target.square())) {
sum += w[offset + t0 + move.ptype()];
sum += w[offset + t1 + move.ptype()];
sum += w[offset + t2 + move.ptype()];
return sum;
}
}
// not related move
offset += PTYPE_SIZE;
if (move.isDrop())
offset += PTYPE_SIZE;
sum += w[offset + t0 + move.ptype()];
sum += w[offset + t1 + move.ptype()];
sum += w[offset + t2 + move.ptype()];
return sum;
}
};
class BookMove : public Feature
{
public:
enum {
DIM = 2
};
BookMove() : Feature("BookMove", DIM)
{
}
double match(const StateInfo& si, const MoveInfo& mi, int offset, const double *w) const
{
if (! si.bookmove[0].isNormal())
return 0.0;
if (mi.move == si.bookmove[0] || mi.move == si.bookmove[1])
return w[offset];
return w[offset+1];
}
};
}
}
#endif /* OSL_MOVE_PROBABILITY_FEATURE_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
additionalEffect.h
osl::CArray
Definition container.h:20
osl::CArray::size
static size_t size()
Definition container.h:76
osl::EffectContent
Definition effectContent.h:11
osl::FixedCapacityVector::isMember
bool isMember(const T &e, const_iterator first, const_iterator last) const
Definition container.h:257
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::Move::ptypeO
PtypeO ptypeO() const
移動後のPtype, i.e., 成る手だった場合成った後
Definition basic_type.h:1162
osl::Move::isPromotion
bool isPromotion() const
Definition basic_type.h:1147
osl::Move::ptype
Ptype ptype() const
Definition basic_type.h:1155
osl::Move::player
Player player() const
Definition basic_type.h:1195
osl::Move::oldPtypeO
PtypeO oldPtypeO() const
移動前のPtypeO, i.e., 成る手だった場合成る前
Definition basic_type.h:1168
osl::Move::isDrop
bool isDrop() const
Definition basic_type.h:1150
osl::Move::capturePtype
Ptype capturePtype() const
Definition basic_type.h:1180
osl::Move::isNormal
bool isNormal() const
INVALID でも PASS でもない.
Definition basic_type.h:1088
osl::Move::isCaptureOrPromotion
bool isCaptureOrPromotion() const
Definition basic_type.h:1149
osl::Move::oldPtype
Ptype oldPtype() const
移動前のPtype, i.e., 成る手だった場合成る前
Definition basic_type.h:1174
osl::Move::to
const Square to() const
Definition basic_type.h:1132
osl::Move::from
const Square from() const
Definition basic_type.h:1125
osl::Neighboring8Direct::hasEffect
static bool hasEffect(const NumEffectState &state, PtypeO ptypeo, Square from, Square target)
ptypeo の駒がfromからtargetの8近傍に直接の利きを持つか
Definition neighboring8Direct.h:108
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::NumEffectState::effectSetAt
const NumBitmapEffect effectSetAt(Square sq) const
Definition numEffectState.h:258
osl::NumEffectState::selectCheapPiece
const Piece selectCheapPiece(PieceMask effect) const
利きの中から安そうな駒を選ぶ
Definition numEffectState.cc:100
osl::NumEffectState::effectedMask
const PieceMask effectedMask(Player pl) const
pl からの利きが(1つ以上)ある駒一覧
Definition numEffectState.h:130
osl::NumEffectState::countEffect
int countEffect(Player player, Square target) const
利きの数を数える.
Definition numEffectState.h:266
osl::NumEffectState::hasEffectByPiece
bool hasEffectByPiece(Piece attack, Square target) const
駒attack が target に利きを持つか (旧hasEffectToと統合)
Definition numEffectState.h:450
osl::NumEffectState::hasEffectAt
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
Definition numEffectState.h:324
osl::NumEffectState::findCheapAttack
const Piece findCheapAttack(Player P, Square square) const
Definition numEffectState.h:560
osl::NumEffectState::hasEffectIf
bool hasEffectIf(PtypeO ptypeo, Square attacker, Square target) const
attackerにptypeoの駒がいると仮定した場合にtargetに利きがあるかどうか を stateをupdateしないで確かめる.
Definition numEffectState.h:465
osl::NumEffectState::inCheck
bool inCheck(Player P) const
Pの玉が王手状態
Definition numEffectState.h:88
osl::NumEffectState::longEffectAt
const mask_t longEffectAt(Square target) const
Definition numEffectState.h:298
osl::NumEffectState::piecesOnBoard
const PieceMask & piecesOnBoard(Player p) const
Definition numEffectState.h:63
osl::Offset
座標の差分
Definition basic_type.h:430
osl::Offset::zero
bool zero() const
Definition basic_type.h:502
osl::PieceMask
駒番号のビットセット.
Definition pieceMask.h:21
osl::PieceMask::getMask
const mask_t getMask(int num) const
Definition pieceMask.h:59
osl::PieceMask::set
void set(int num)
Definition pieceMask.h:48
osl::PieceMask::clearBit
void clearBit()
unpromote(PTYPE) の駒のbit を消す
Definition pieceMask.h:74
osl::PieceMask::any
bool any() const
Definition pieceMask.h:57
osl::PieceStand::order
static const CArray< Ptype, 7 > order
持駒の表示で良く使われる順番.
Definition bits/pieceStand.h:41
osl::Piece
駒.
Definition basic_type.h:788
osl::Piece::ptypeO
PtypeO ptypeO() const
Definition basic_type.h:824
osl::Piece::ptype
Ptype ptype() const
Definition basic_type.h:821
osl::Piece::isPromoted
bool isPromoted() const
promoteした駒かどうかをチェックする
Definition basic_type.h:898
osl::Piece::square
const Square square() const
Definition basic_type.h:832
osl::Piece::isEmpty
bool isEmpty() const
Definition basic_type.h:913
osl::Piece::isEdge
bool isEdge() const
Definition basic_type.h:919
osl::Piece::owner
Player owner() const
Definition basic_type.h:963
osl::Piece::isPiece
bool isPiece() const
Definition basic_type.h:953
osl::Piece::isOnBoardByOwner
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition basic_type.h:852
osl::Piece::number
int number() const
Definition basic_type.h:828
osl::SimpleState::pieceOnBoard
const Piece pieceOnBoard(Square sq) const
Definition simpleState.h:170
osl::SimpleState::hasPieceOnStand
bool hasPieceOnStand(Player player, Ptype ptype) const
Definition simpleState.h:191
osl::SimpleState::kingPiece
const Piece kingPiece() const
Definition simpleState.h:83
osl::SimpleState::turn
Player turn() const
Definition simpleState.h:220
osl::SimpleState::canDropPawnTo
bool canDropPawnTo(Player player, int x) const
xの筋に歩を打てる
Definition simpleState.h:155
osl::SimpleState::pieceOf
const Piece pieceOf(int num) const
Definition simpleState.h:76
osl::SimpleState::isEmptyBetween
bool isEmptyBetween(Square from, Square to, Offset offset, bool pieceExistsAtTo=false) const
Definition simpleState.h:267
osl::SimpleState::kingSquare
Square kingSquare() const
Definition simpleState.h:94
osl::SimpleState::countPiecesOnStand
int countPiecesOnStand(Player pl, Ptype ptype) const
持駒の枚数を数える
Definition simpleState.h:182
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition simpleState.h:167
osl::Square
Definition basic_type.h:532
osl::Square::index
unsigned int index() const
Definition basic_type.h:572
osl::Square::isPieceStand
bool isPieceStand() const
Definition basic_type.h:576
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
osl::Square::isNeighboring8
bool isNeighboring8(Square to) const
Definition basic_type.cc:202
osl::Square::canPromote
bool canPromote() const
Definition basic_type.h:659
osl::Square::squareForBlack
const Square squareForBlack(Player player) const
Definition basic_type.h:598
osl::Square::isOnBoard
bool isOnBoard() const
盤面上を表すかどうかの判定． 1<=x() && x()<=9 && 1<=y() && y()<=9 Squareの内部表現に依存する．
Definition basic_type.h:583
osl::Square::isOnBoardRegion
bool isOnBoardRegion() const
squareがONBOARD_MINとONBOARD_MAXの間にある
Definition basic_type.h:641
osl::Square::x
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
osl::Square::square
unsigned int square
Definition basic_type.h:533
osl::checkmate::King8Info
敵玉の8近傍の状態を表す.
Definition king8Info.h:29
osl::checkmate::King8Info::liberty
unsigned int liberty() const
8-15 bit 目を 0-7bitにshiftして返す
Definition king8Info.h:54
osl::checkmate::King8Info::libertyCount
unsigned int libertyCount() const
libertyの数
Definition king8Info.h:82
osl::container::MoveStack::hasLastMove
bool hasLastMove(size_t last=1) const
Definition moveStack.h:27
osl::container::MoveStack::lastMove
const Move lastMove(size_t last=1) const
Definition moveStack.h:28
osl::container::PieceMask64::takeOneBit
int takeOneBit()
Definition pieceMask64.h:82
osl::effect::NumBitmapEffect
現在の定義 (2005/3/4以降)
Definition numBitmapEffect.h:29
osl::misc::GeneralMask::any
bool any() const
Definition mask.h:298
osl::misc::GeneralMask::takeOneBit
int takeOneBit()
non-zeroのmaskのsetされているビットをLSBから探し，その番号を返す 副作用としてmaskの対応するビットをクリアする
Definition mask.h:265
osl::move_probability::AddEffectLong::DIM
@ DIM
Definition move_probability/feature.h:837
osl::move_probability::AddEffectLong::addOne
static double addOne(Direction dir, const StateInfo &state, const MoveInfo &move, int offset, const double *w)
Definition move_probability/feature.h:842
osl::move_probability::AddEffectLong::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:854
osl::move_probability::AddEffectLong::AddEffectLong
AddEffectLong()
Definition move_probability/feature.h:839
osl::move_probability::AttackFromOpposingSliders::AttackFromOpposingSliders
AttackFromOpposingSliders()
Definition move_probability/feature.h:594
osl::move_probability::AttackFromOpposingSliders::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:597
osl::move_probability::AttackKing8Long::DIM
@ DIM
Definition move_probability/feature.h:1262
osl::move_probability::AttackKing8Long::AttackKing8Long
AttackKing8Long()
Definition move_probability/feature.h:1264
osl::move_probability::AttackKing8Long::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:1267
osl::move_probability::AttackToOpposingSliders::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:619
osl::move_probability::AttackToOpposingSliders::AttackToOpposingSliders
AttackToOpposingSliders()
Definition move_probability/feature.h:616
osl::move_probability::BishopAttack::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:985
osl::move_probability::BishopAttack::addSquare
static double addSquare(Square target, const StateInfo &info, int offset, const double *w)
Definition move_probability/feature.h:930
osl::move_probability::BishopAttack::addOne
static double addOne(const StateInfo &info, Square to, int offset, const double *w)
Definition move_probability/feature.h:945
osl::move_probability::BishopAttack::DIM
@ DIM
Definition move_probability/feature.h:925
osl::move_probability::BishopAttack::PatternCacheSize
@ PatternCacheSize
Definition move_probability/feature.h:924
osl::move_probability::BishopAttack::BishopAttack
BishopAttack()
Definition move_probability/feature.h:927
osl::move_probability::BlockLongFrom::findAll
static double findAll(const StateInfo &state, Move move, const double *w, int offset=0)
Definition move_probability/feature.h:790
osl::move_probability::BlockLongFrom::DIM
@ DIM
Definition move_probability/feature.h:785
osl::move_probability::BlockLongFrom::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:796
osl::move_probability::BlockLongFrom::BlockLongFrom
BlockLongFrom()
Definition move_probability/feature.h:787
osl::move_probability::BlockLong::makeLongAttackOne
static void makeLongAttackOne(StateInfo &info, Piece piece, Direction d)
Definition feature_.cc:147
osl::move_probability::BlockLong::updateCache
static void updateCache(StateInfo &)
Definition feature_.cc:113
osl::move_probability::BlockLong::findAll
static double findAll(const StateInfo &state, Move move, const double *w, int offset=0)
Definition move_probability/feature.h:764
osl::move_probability::BlockLong::longAttackIndex
static int longAttackIndex(osl::PtypeO ptypeo)
Definition move_probability/feature.h:713
osl::move_probability::BlockLong::findAll
static double findAll(const StateInfo &state, Player P, Square target, const double *w, int offset)
Definition move_probability/feature.h:746
osl::move_probability::BlockLong::addPiece
static double addPiece(const StateInfo &state, Piece piece, Square to, const double *w, int offset)
Definition move_probability/feature.h:727
osl::move_probability::BlockLong::OptionSize
@ OptionSize
Definition move_probability/feature.h:706
osl::move_probability::BlockLong::BasicAttack
@ BasicAttack
Definition move_probability/feature.h:705
osl::move_probability::BlockLong::DIM
@ DIM
Definition move_probability/feature.h:708
osl::move_probability::BlockLong::LongAttackSize
@ LongAttackSize
Definition move_probability/feature.h:707
osl::move_probability::BlockLong::AttackPtype
@ AttackPtype
Definition move_probability/feature.h:704
osl::move_probability::BlockLong::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:772
osl::move_probability::BlockLong::BlockLong
BlockLong()
Definition move_probability/feature.h:710
osl::move_probability::BlockLong::ptypeSupport
static int ptypeSupport(Ptype moved, bool has_support)
Definition move_probability/feature.h:742
osl::move_probability::BookMove::match
double match(const StateInfo &si, const MoveInfo &mi, int offset, const double *w) const
Definition move_probability/feature.h:1749
osl::move_probability::BookMove::BookMove
BookMove()
Definition move_probability/feature.h:1746
osl::move_probability::BookMove::DIM
@ DIM
Definition move_probability/feature.h:1744
osl::move_probability::BreakThreatmate::BreakThreatmate
BreakThreatmate()
Definition move_probability/feature.h:1035
osl::move_probability::BreakThreatmate::isDefendingThreatmate
static bool isDefendingThreatmate(Move move, Move threatmate, const NumEffectState &state)
Definition move_probability/feature.h:1047
osl::move_probability::BreakThreatmate::OpenRoadBase
@ OpenRoadBase
Definition move_probability/feature.h:1028
osl::move_probability::BreakThreatmate::AddEffect8Size
@ AddEffect8Size
Definition move_probability/feature.h:1031
osl::move_probability::BreakThreatmate::PatternCacheSize
@ PatternCacheSize
Definition move_probability/feature.h:1026
osl::move_probability::BreakThreatmate::OtherMoveBase
@ OtherMoveBase
Definition move_probability/feature.h:1032
osl::move_probability::BreakThreatmate::AddEffect8Base
@ AddEffect8Base
Definition move_probability/feature.h:1031
osl::move_probability::BreakThreatmate::KingMoveSize
@ KingMoveSize
Definition move_probability/feature.h:1029
osl::move_probability::BreakThreatmate::OtherMoveSize
@ OtherMoveSize
Definition move_probability/feature.h:1032
osl::move_probability::BreakThreatmate::CaptureBase
@ CaptureBase
Definition move_probability/feature.h:1030
osl::move_probability::BreakThreatmate::DIM
@ DIM
Definition move_probability/feature.h:1033
osl::move_probability::BreakThreatmate::KingMoveBase
@ KingMoveBase
Definition move_probability/feature.h:1029
osl::move_probability::BreakThreatmate::AddEffectSize
@ AddEffectSize
Definition move_probability/feature.h:1027
osl::move_probability::BreakThreatmate::OpenRoadSize
@ OpenRoadSize
Definition move_probability/feature.h:1028
osl::move_probability::BreakThreatmate::CaptureSize
@ CaptureSize
Definition move_probability/feature.h:1030
osl::move_probability::BreakThreatmate::isKingMove
static bool isKingMove(Move move)
Definition move_probability/feature.h:1038
osl::move_probability::BreakThreatmate::isOpeningKingRoad
static bool isOpeningKingRoad(Move move, Square king)
Definition move_probability/feature.h:1042
osl::move_probability::BreakThreatmate::match
double match(const StateInfo &info, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:1080
osl::move_probability::BreakThreatmate::isDefendingKing8
static bool isDefendingKing8(Move move, Square king, const NumEffectState &state)
Definition move_probability/feature.h:1064
osl::move_probability::CapturePtype::CapturePtype
CapturePtype()
Definition move_probability/feature.h:133
osl::move_probability::CapturePtype::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:136
osl::move_probability::CheckFeature::RELATIVE_Y_CLASS
@ RELATIVE_Y_CLASS
Definition move_probability/feature.h:43
osl::move_probability::CheckFeature::CHECK_CLASS
@ CHECK_CLASS
Definition move_probability/feature.h:43
osl::move_probability::CheckFeature::sign
static int sign(const NumEffectState &state, Move move, Player player)
Definition move_probability/feature.h:54
osl::move_probability::CheckFeature::CheckFeature
CheckFeature()
Definition move_probability/feature.h:44
osl::move_probability::CheckFeature::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:62
osl::move_probability::CheckFeature::checkIndex
static int checkIndex(const MoveInfo &move)
Definition move_probability/feature.h:48
osl::move_probability::CheckmateIfCapture::DIM
@ DIM
Definition move_probability/feature.h:1227
osl::move_probability::CheckmateIfCapture::hasSafeCapture
static bool hasSafeCapture(NumEffectState &state, Move)
Definition feature_.cc:205
osl::move_probability::CheckmateIfCapture::CheckmateIfCapture
CheckmateIfCapture()
Definition move_probability/feature.h:1229
osl::move_probability::CheckmateIfCapture::match
double match(const StateInfo &info, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:1232
osl::move_probability::ContinueCapture::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:158
osl::move_probability::ContinueCapture::ContinueCapture
ContinueCapture()
Definition move_probability/feature.h:157
osl::move_probability::CoverFork::CoverFork
CoverFork()
Definition move_probability/feature.h:1538
osl::move_probability::CoverFork::match
double match(const StateInfo &si, const MoveInfo &mi, int offset, const double *w) const
Definition move_probability/feature.h:1554
osl::move_probability::CoverFork::DIM
@ DIM
Definition move_probability/feature.h:1536
osl::move_probability::CoverFork::defending
static bool defending(const NumEffectState &state, Move move, Square target)
Definition move_probability/feature.h:1541
osl::move_probability::CoverPawn::match
double match(const StateInfo &si, const MoveInfo &mi, int offset, const double *w) const
Definition move_probability/feature.h:1365
osl::move_probability::CoverPawn::CoverPawn
CoverPawn()
Definition move_probability/feature.h:1362
osl::move_probability::CoverPawn::DIM
@ DIM
Definition move_probability/feature.h:1360
osl::move_probability::DropAfterOpposingPawn::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:1327
osl::move_probability::DropAfterOpposingPawn::DIM
@ DIM
Definition move_probability/feature.h:1322
osl::move_probability::DropAfterOpposingPawn::DropAfterOpposingPawn
DropAfterOpposingPawn()
Definition move_probability/feature.h:1324
osl::move_probability::DropCaptured::DropCaptured
DropCaptured()
Definition move_probability/feature.h:172
osl::move_probability::DropCaptured::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:173
osl::move_probability::EscapeThreatened::match
double match(const StateInfo &si, const MoveInfo &mi, int offset, const double *w) const
Definition move_probability/feature.h:1697
osl::move_probability::EscapeThreatened::EscapeThreatened
EscapeThreatened()
Definition move_probability/feature.h:1694
osl::move_probability::EscapeThreatened::DIM
@ DIM
Definition move_probability/feature.h:1692
osl::move_probability::Feature::name
std::string name() const
Definition move_probability/feature.h:26
osl::move_probability::Feature::match
virtual double match(const StateInfo &, const MoveInfo &, int offset, const double *) const =0
osl::move_probability::Feature::dim
int dim
Definition move_probability/feature.h:19
osl::move_probability::Feature::my_name
std::string my_name
Definition move_probability/feature.h:18
osl::move_probability::Feature::~Feature
virtual ~Feature()
Definition feature_.cc:8
osl::move_probability::Feature::classifyEffect9
static int classifyEffect9(const NumEffectState &state, Player player, Square to)
Definition move_probability/feature.h:30
osl::move_probability::Feature::dimension
size_t dimension() const
Definition move_probability/feature.h:28
osl::move_probability::Feature::Feature
Feature(std::string n, size_t d)
Definition move_probability/feature.h:21
osl::move_probability::FromEffectLong::FromEffectLong
FromEffectLong()
Definition move_probability/feature.h:409
osl::move_probability::FromEffectLong::match
double match(const StateInfo &state_info, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:412
osl::move_probability::FromEffect::match
double match(const StateInfo &state_info, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:335
osl::move_probability::FromEffect::FromEffect
FromEffect()
Definition move_probability/feature.h:332
osl::move_probability::King5x5Ptype::ONE_DIM
@ ONE_DIM
Definition move_probability/feature.h:1431
osl::move_probability::King5x5Ptype::DIM
@ DIM
Definition move_probability/feature.h:1432
osl::move_probability::King5x5Ptype::King5x5Ptype
King5x5Ptype()
Definition move_probability/feature.h:1434
osl::move_probability::King5x5Ptype::match
double match(const StateInfo &si, const MoveInfo &mi, int offset, const double *w) const
Definition move_probability/feature.h:1455
osl::move_probability::King5x5Ptype::addOne
static double addOne(Player king, Square center, const StateInfo &si, const MoveInfo &mi, int offset, const double *w)
Definition move_probability/feature.h:1437
osl::move_probability::KingBlockade::BlockFront
@ BlockFront
Definition move_probability/feature.h:1468
osl::move_probability::KingBlockade::BlockLastOne
@ BlockLastOne
Definition move_probability/feature.h:1468
osl::move_probability::KingBlockade::StandCount
@ StandCount
Definition move_probability/feature.h:1467
osl::move_probability::KingBlockade::DIM
@ DIM
Definition move_probability/feature.h:1470
osl::move_probability::KingBlockade::BlockSideOther
@ BlockSideOther
Definition move_probability/feature.h:1469
osl::move_probability::KingBlockade::BlockBack
@ BlockBack
Definition move_probability/feature.h:1469
osl::move_probability::KingBlockade::BlockSideWide
@ BlockSideWide
Definition move_probability/feature.h:1469
osl::move_probability::KingBlockade::match
double match(const StateInfo &si, const MoveInfo &mi, int offset, const double *w) const
Definition move_probability/feature.h:1490
osl::move_probability::KingBlockade::blockAll
static bool blockAll(const King8Info &ki, Square king, Move move, const NumEffectState &state, const CArray< Direction, 3 > &directions)
Definition move_probability/feature.h:1475
osl::move_probability::KingBlockade::KingBlockade
KingBlockade()
Definition move_probability/feature.h:1472
osl::move_probability::KingRelativeX::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:291
osl::move_probability::KingRelativeX::ONE_DIM
@ ONE_DIM
Definition move_probability/feature.h:287
osl::move_probability::KingRelativeX::KingRelativeX
KingRelativeX()
Definition move_probability/feature.h:288
osl::move_probability::KingRelativeY::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:255
osl::move_probability::KingRelativeY::ONE_DIM
@ ONE_DIM
Definition move_probability/feature.h:251
osl::move_probability::KingRelativeY::KingRelativeY
KingRelativeY()
Definition move_probability/feature.h:252
osl::move_probability::LanceAttack::DIM
@ DIM
Definition move_probability/feature.h:872
osl::move_probability::LanceAttack::PatternCacheSize
@ PatternCacheSize
Definition move_probability/feature.h:871
osl::move_probability::LanceAttack::LanceAttack
LanceAttack()
Definition move_probability/feature.h:874
osl::move_probability::LanceAttack::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:877
osl::move_probability::LongRecapture::DIM
@ DIM
Definition move_probability/feature.h:807
osl::move_probability::LongRecapture::LongRecapture
LongRecapture()
Definition move_probability/feature.h:809
osl::move_probability::LongRecapture::match
double match(const StateInfo &info, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:812
osl::move_probability::LureDefender::DIM
@ DIM
Definition move_probability/feature.h:1166
osl::move_probability::LureDefender::ATTACK_DIM
@ ATTACK_DIM
Definition move_probability/feature.h:1165
osl::move_probability::LureDefender::match
static double match(const NumEffectState &state, Move move, int see, const StateInfo::pinned_gs_t &pinned_list, int offset, const double *w)
Definition move_probability/feature.h:1171
osl::move_probability::LureDefender::match
double match(const StateInfo &info, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:1216
osl::move_probability::LureDefender::LureDefender
LureDefender()
Definition move_probability/feature.h:1168
osl::move_probability::MoveFromOpposingSliders::longPtype
static int longPtype(const NumEffectState &state, Square position, Player player)
Definition move_probability/feature.h:567
osl::move_probability::MoveFromOpposingSliders::MoveFromOpposingSliders
MoveFromOpposingSliders()
Definition move_probability/feature.h:564
osl::move_probability::MoveFromOpposingSliders::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:580
osl::move_probability::OpposingPawn::DIM
@ DIM
Definition move_probability/feature.h:1289
osl::move_probability::OpposingPawn::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:1294
osl::move_probability::OpposingPawn::OpposingPawn
OpposingPawn()
Definition move_probability/feature.h:1291
osl::move_probability::PatternBase
Definition move_probability/feature.h:511
osl::move_probability::PatternBase::PatternBase
PatternBase(int x, int y)
Definition move_probability/feature.h:518
osl::move_probability::PatternBase< false >::DIM
@ DIM
Definition move_probability/feature.h:516
osl::move_probability::PatternBase< false >::PromotionSize
@ PromotionSize
Definition move_probability/feature.h:515
osl::move_probability::PatternBase::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:522
osl::move_probability::PatternBase< false >::black_dy
int black_dy
Definition move_probability/feature.h:512
osl::move_probability::PatternBase< false >::dx
int dx
Definition move_probability/feature.h:512
osl::move_probability::PatternBase< false >::name
static std::string name(int x, int y)
Definition move_probability/feature.h:550
osl::move_probability::PatternCommon::PatternCommon
PatternCommon(const std::string &name, int dim)
Definition move_probability/feature.h:487
osl::move_probability::PatternCommon::updateCacheOne
static void updateCacheOne(Square target, StateInfo &info)
Definition feature_.cc:25
osl::move_probability::PatternCommon::addOne
double addOne(const StateInfo &state, int offset, const double *w, Square position) const
Definition move_probability/feature.h:490
osl::move_probability::PatternCommon::updateCache
static void updateCache(StateInfo &info)
Definition feature_.cc:14
osl::move_probability::PatternCommon::OpKingSize
@ OpKingSize
Definition move_probability/feature.h:477
osl::move_probability::PatternCommon::LastToSize
@ LastToSize
Definition move_probability/feature.h:481
osl::move_probability::PatternCommon::MyKingSize
@ MyKingSize
Definition move_probability/feature.h:478
osl::move_probability::PatternCommon::LastToBase
@ LastToBase
Definition move_probability/feature.h:481
osl::move_probability::PatternCommon::OpKingBase
@ OpKingBase
Definition move_probability/feature.h:477
osl::move_probability::PatternCommon::SquareDim
@ SquareDim
Definition move_probability/feature.h:483
osl::move_probability::PatternCommon::MyKingBase
@ MyKingBase
Definition move_probability/feature.h:478
osl::move_probability::PatternCommon::AttackSize
@ AttackSize
Definition move_probability/feature.h:475
osl::move_probability::PatternCommon::AttackBase
@ AttackBase
Definition move_probability/feature.h:475
osl::move_probability::PatternCommon::LastEffectChangedBase
@ LastEffectChangedBase
Definition move_probability/feature.h:482
osl::move_probability::PatternCommon::PromotionSize
@ PromotionSize
Definition move_probability/feature.h:479
osl::move_probability::PatternCommon::LastEffectChangedSize
@ LastEffectChangedSize
Definition move_probability/feature.h:482
osl::move_probability::PatternCommon::EffectSize
@ EffectSize
Definition move_probability/feature.h:476
osl::move_probability::PatternCommon::PinOpenBase
@ PinOpenBase
Definition move_probability/feature.h:480
osl::move_probability::PatternCommon::SupportSize
@ SupportSize
Definition move_probability/feature.h:474
osl::move_probability::PatternCommon::PinOpenSize
@ PinOpenSize
Definition move_probability/feature.h:480
osl::move_probability::PatternCommon::OneDim
@ OneDim
Definition move_probability/feature.h:485
osl::move_probability::PatternCommon::PatternCacheSize
@ PatternCacheSize
Definition move_probability/feature.h:484
osl::move_probability::PatternCommon::EffectBase
@ EffectBase
Definition move_probability/feature.h:476
osl::move_probability::PatternCommon::PromotionBase
@ PromotionBase
Definition move_probability/feature.h:479
osl::move_probability::PawnAttack::EFFECT_DIM
@ EFFECT_DIM
Definition move_probability/feature.h:642
osl::move_probability::PawnAttack::PawnSize
@ PawnSize
Definition move_probability/feature.h:644
osl::move_probability::PawnAttack::BasicSize
@ BasicSize
Definition move_probability/feature.h:643
osl::move_probability::PawnAttack::DIM
@ DIM
Definition move_probability/feature.h:645
osl::move_probability::PawnAttack::PTYPE2_DIM
@ PTYPE2_DIM
Definition move_probability/feature.h:641
osl::move_probability::PawnAttack::PawnAttack
PawnAttack()
Definition move_probability/feature.h:647
osl::move_probability::PawnAttack::matchPtype
double matchPtype(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:665
osl::move_probability::PawnAttack::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:689
osl::move_probability::PawnAttack::squareStatus
std::pair< int, int > squareStatus(const NumEffectState &state, Player player, Square to, Square &front) const
Definition move_probability/feature.h:650
osl::move_probability::PromotionBySacrifice::PromotionBySacrifice
PromotionBySacrifice()
Definition move_probability/feature.h:1616
osl::move_probability::PromotionBySacrifice::DIM
@ DIM
Definition move_probability/feature.h:1614
osl::move_probability::PromotionBySacrifice::match
double match(const StateInfo &si, const MoveInfo &mi, int offset, const double *w) const
Definition move_probability/feature.h:1619
osl::move_probability::RookAttack::RookAttack
RookAttack()
Definition move_probability/feature.h:1004
osl::move_probability::RookAttack::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:1007
osl::move_probability::RookAttack::DirectionSize
@ DirectionSize
Definition move_probability/feature.h:1001
osl::move_probability::RookAttack::DIM
@ DIM
Definition move_probability/feature.h:1002
osl::move_probability::SacrificeAttack::match
double match(const StateInfo &si, const MoveInfo &mi, int offset, const double *w) const
Definition move_probability/feature.h:1406
osl::move_probability::SacrificeAttack::DIM
@ DIM
Definition move_probability/feature.h:1401
osl::move_probability::SacrificeAttack::StandCount
@ StandCount
Definition move_probability/feature.h:1400
osl::move_probability::SacrificeAttack::SacrificeAttack
SacrificeAttack()
Definition move_probability/feature.h:1403
osl::move_probability::SeeFeature::SeeFeature
SeeFeature()
Definition move_probability/feature.h:99
osl::move_probability::SeeFeature::YClass
@ YClass
Definition move_probability/feature.h:98
osl::move_probability::SeeFeature::SeeClass
@ SeeClass
Definition move_probability/feature.h:98
osl::move_probability::SeeFeature::ProgressClass
@ ProgressClass
Definition move_probability/feature.h:98
osl::move_probability::SeeFeature::seeIndex
static int seeIndex(int see)
Definition move_probability/feature.h:102
osl::move_probability::SeeFeature::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:116
osl::move_probability::SendOff::DIM
@ DIM
Definition move_probability/feature.h:1148
osl::move_probability::SendOff::SendOff
SendOff()
Definition move_probability/feature.h:1150
osl::move_probability::SendOff::match
double match(const StateInfo &info, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:1153
osl::move_probability::SquareX::fromTo
static int fromTo(Square to, Square from)
Definition move_probability/feature.h:224
osl::move_probability::SquareX::SquareX
SquareX()
Definition move_probability/feature.h:221
osl::move_probability::SquareX::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:228
osl::move_probability::SquareY::fromTo
static int fromTo(Square to, Square from)
Definition move_probability/feature.h:196
osl::move_probability::SquareY::SquareY
SquareY()
Definition move_probability/feature.h:193
osl::move_probability::SquareY::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:200
osl::move_probability::SquareY::DIM
@ DIM
Definition move_probability/feature.h:191
osl::move_probability::TakeBackFeature::TakeBackFeature
TakeBackFeature()
Definition move_probability/feature.h:77
osl::move_probability::TakeBackFeature::match
double match(const StateInfo &state, const MoveInfo &move, int offset, const double *w) const
Definition move_probability/feature.h:80
osl::move_probability::ThreatmateByCapture::match
double match(const StateInfo &si, const MoveInfo &mi, int offset, const double *w) const
Definition move_probability/feature.h:1591
osl::move_probability::ThreatmateByCapture::ThreatmateByCapture
ThreatmateByCapture()
Definition move_probability/feature.h:1588
osl::move_probability::ThreatmateByCapture::DIM
@ DIM
Definition move_probability/feature.h:1586
osl::move_probability::ToEffectLong::ToEffectLong
ToEffectLong()
Definition move_probability/feature.h:442
osl::move_probability::ToEffectLong::match
double match(const StateInfo &state_info, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:445
osl::move_probability::ToEffect::ToEffect
ToEffect()
Definition move_probability/feature.h:353
osl::move_probability::ToEffect::find
static const Piece find(const NumEffectState &state, Square to, const PieceMask &remove, Player player)
Definition move_probability/feature.h:356
osl::move_probability::ToEffect::supportAttack
static size_t supportAttack(const StateInfo &info, Square to, Move move)
Definition move_probability/feature.h:388
osl::move_probability::ToEffect::match
double match(const StateInfo &state, const MoveInfo &info, int offset, const double *w) const
Definition move_probability/feature.h:394
osl::move_probability::ToEffect::supportAttack
static void supportAttack(const NumEffectState &state, Square to, const PieceMask &my_pin, const PieceMask &op_pin, Player turn, std::pair< Ptype, Ptype > &out)
Definition move_probability/feature.h:366
osl::move_probability::ToEffect::supportAttack
static void supportAttack(const StateInfo &info, Square to, Move move, std::pair< Ptype, Ptype > &out)
Definition move_probability/feature.h:376
moveInfo.h
osl::effect
Definition effectedNumTable.h:8
osl::misc::mask_t
GeneralMask< mask_int_t > mask_t
Definition mask.h:351
osl::move_probability
Definition move_probability/feature.h:15
osl::move_probability::Pattern
PatternBase< false > Pattern
Definition move_probability/feature.h:558
osl::move_probability::PatternPromotion
PatternBase< true > PatternPromotion
Definition move_probability/feature.h:559
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::ROOK
@ ROOK
Definition basic_type.h:100
osl::BISHOP
@ BISHOP
Definition basic_type.h:99
osl::PROOK
@ PROOK
Definition basic_type.h:92
osl::PAWN
@ PAWN
Definition basic_type.h:95
osl::PTYPE_EDGE
@ PTYPE_EDGE
Definition basic_type.h:86
osl::KING
@ KING
Definition basic_type.h:93
osl::KNIGHT
@ KNIGHT
Definition basic_type.h:97
osl::PTYPE_EMPTY
@ PTYPE_EMPTY
Definition basic_type.h:85
osl::SILVER
@ SILVER
Definition basic_type.h:98
osl::PTYPE_BASIC_MIN
@ PTYPE_BASIC_MIN
Definition basic_type.h:103
osl::GOLD
@ GOLD
Definition basic_type.h:94
osl::PBISHOP
@ PBISHOP
Definition basic_type.h:91
osl::LANCE
@ LANCE
Definition basic_type.h:96
osl::Ptype_Table
const PtypeTable Ptype_Table
Definition tables.cc:97
osl::PTYPE_SIZE
const int PTYPE_SIZE
Definition basic_type.h:107
osl::getPtype
Ptype getPtype(PtypeO ptypeO)
Definition basic_type.h:217
osl::PTYPEO_SIZE
const int PTYPEO_SIZE
Definition basic_type.h:308
osl::canPromote
bool canPromote(Ptype ptype)
ptypeがpromote可能な型かどうかのチェック promote済みの場合はfalseを返す
Definition basic_type.h:147
osl::longToShort
constexpr Direction longToShort(Direction d)
Definition basic_type.h:380
osl::unpromote
Ptype unpromote(Ptype ptype)
ptypeがpromote後の型の時に，promote前の型を返す． promoteしていない型の時はそのまま返す
Definition basic_type.h:157
osl::Board_Table
const BoardTable Board_Table
Definition tables.cc:95
osl::getOwner
Player getOwner(PtypeO ptypeO)
Definition basic_type.h:256
osl::Direction
Direction
Definition basic_type.h:310
osl::R
@ R
Definition basic_type.h:317
osl::D
@ D
Definition basic_type.h:319
osl::UL
@ UL
Definition basic_type.h:313
osl::DR
@ DR
Definition basic_type.h:320
osl::U
@ U
Definition basic_type.h:314
osl::L
@ L
Definition basic_type.h:316
osl::UR
@ UR
Definition basic_type.h:315
osl::DL
@ DL
Definition basic_type.h:318
osl::ptypeOIndex
unsigned int ptypeOIndex(PtypeO ptypeo)
Definition basic_type.h:205
osl::Offset32
Offset32Base< 8, 9 > Offset32
Definition offset32.h:63
osl::sign
constexpr int sign(Player player)
Definition basic_type.h:23
osl::Player
Player
Definition basic_type.h:8
osl::WHITE
@ WHITE
Definition basic_type.h:10
osl::BLACK
@ BLACK
Definition basic_type.h:9
osl::PtypeO
PtypeO
Player + Ptype [-15, 15] PtypeO の O は Owner の O.
Definition basic_type.h:199
osl::isLong
constexpr bool isLong(Direction d)
Definition basic_type.h:350
osl::alt
constexpr Player alt(Player player)
Definition basic_type.h:13
osl::promote
Ptype promote(Ptype ptype)
promote可能なptypeに対して，promote後の型を返す promote不可のptypeを与えてはいけない．
Definition basic_type.h:173
osl::captured
PtypeO captured(PtypeO ptypeO)
unpromoteすると共に，ownerを反転する．
Definition basic_type.h:264
neighboring8Direct.h
stateInfo.h
osl::AdditionalEffect::hasEffect
static bool hasEffect(const NumEffectState &, Square target, Player attack)
target に attack の追加利きが一つでもあるか． 相手の影利きが先にある場合は対象としない．
Definition additionalEffect.cc:5
osl::DirectionPlayerTraits
Definition directionTraits.h:242
osl::PtypeFuns
Definition ptypeTraits.h:311
osl::PtypeFuns::indexMask
static const uint64_t indexMask
Definition ptypeTraits.h:318
osl::container::Square8::isMember
bool isMember(Square position) const
Definition square8.h:22
osl::misc::BitOp::bsf
static int bsf(Integer mask)
Definition mask.h:138
osl::move_probability::MoveInfo
Definition moveInfo.h:14
osl::move_probability::MoveInfo::see
int see
Definition moveInfo.h:16
osl::move_probability::MoveInfo::player
Player player
Definition moveInfo.h:18
osl::move_probability::MoveInfo::check
bool check
Definition moveInfo.h:17
osl::move_probability::MoveInfo::standIndex
int standIndex(const NumEffectState &state) const
Definition moveInfo.h:22
osl::move_probability::MoveInfo::move
Move move
Definition moveInfo.h:15
osl::move_probability::MoveInfo::open_check
bool open_check
Definition moveInfo.h:17
osl::move_probability::PinnedGeneral
Definition pinnedGeneral.h:12
osl::move_probability::StateInfo
Definition stateInfo.h:21
osl::move_probability::StateInfo::pinned_gs_t
FixedCapacityVector< PinnedGeneral, 64 > pinned_gs_t
Definition stateInfo.h:37
osl::move_probability::StateInfo::bookmove
CArray< Move, 2 > bookmove
Definition stateInfo.h:44
osl::move_probability::StateInfo::threatened
CArray< Piece, 2 > threatened
Definition stateInfo.h:26
osl::move_probability::StateInfo::sendoffs
Square8 sendoffs
Definition stateInfo.h:36
osl::move_probability::StateInfo::possible_threatmate_ptype
unsigned int possible_threatmate_ptype
Definition stateInfo.h:43
osl::move_probability::StateInfo::state
const NumEffectState * state
Definition stateInfo.h:22
osl::move_probability::StateInfo::king8_long_pieces
PieceVector king8_long_pieces
Definition stateInfo.h:25
osl::move_probability::StateInfo::history
const MoveStack * history
Definition stateInfo.h:23
osl::move_probability::StateInfo::threatmate_move
Move threatmate_move
Definition stateInfo.h:35
osl::move_probability::StateInfo::pattern_square_t
CArray< int, 16 > pattern_square_t
Definition stateInfo.h:29
osl::move_probability::StateInfo::progress8
int progress8() const
Definition stateInfo.h:92
osl::move_probability::StateInfo::move_candidate_exists
CArray< bool, 2 > move_candidate_exists
Definition stateInfo.h:39
osl::move_probability::StateInfo::exchange_pins
CArray< pinned_gs_t, 2 > exchange_pins
Definition stateInfo.h:38
osl::move_probability::StateInfo::long_attack_t
FixedCapacityVector< int, 8 > long_attack_t
Definition stateInfo.h:27
osl::move_probability::StateInfo::pinByOpposingSliders
bool pinByOpposingSliders(Piece p) const
Definition stateInfo.h:83
osl::move_probability::StateInfo::pattern_cache
CArray< pattern_square_t, Square::SIZE > pattern_cache
Definition stateInfo.h:30
osl::move_probability::StateInfo::king8Info
King8Info king8Info(Player pl) const
Definition stateInfo.h:88
osl::move_probability::StateInfo::pin
CArray< PieceMask, 2 > pin
Definition stateInfo.h:34
osl::move_probability::StateInfo::copy
NumEffectState copy
Definition stateInfo.h:40
osl::move_probability::StateInfo::long_attack_cache
CArray2d< long_attack_t, 40, 8 > long_attack_cache
Definition stateInfo.h:28
osl::move_probability::StateInfo::pin_by_opposing_sliders
PieceVector pin_by_opposing_sliders
Definition stateInfo.h:25