majorPiece.cc
Go to the documentation of this file.
#include "osl/eval/majorPiece.h"
#include "osl/mobility/rookMobility.h"
#include <algorithm>
using osl::MultiInt;
template <bool Opening, osl::Ptype MajorBasic>
osl::CArray<int, 18>
osl::eval::ml::MajorY<Opening, MajorBasic>::table;
template <bool Opening, osl::Ptype MajorBasic>
void osl::eval::ml::
MajorY<Opening, MajorBasic>::setUp(const Weights &weights)
{
for (size_t i = 0; i < weights.dimension(); ++i)
{
table[i] = weights.value(i);
}
}
␌
template <bool Opening>
int osl::eval::ml::RookPawn<Opening>::weight;
template <bool Opening>
void osl::eval::ml::
RookPawn<Opening>::setUp(const Weights &weights)
{
weight = weights.value(0);
}
template <bool Opening>
int osl::eval::ml::RookPawn<Opening>::eval(const NumEffectState &state)
{
int result = 0;
for (int i = PtypeTraits<ROOK>::indexMin;
i < PtypeTraits<ROOK>::indexLimit;
++i)
{
const Piece piece = state.pieceOf(i);
if (piece.isOnBoard() && !piece.square().canPromote(piece.owner()) &&
!state.isPawnMaskSet(piece.owner(), piece.square().x()))
{
if (piece.owner() == BLACK)
result += weight;
else
result -= weight;
}
}
return result;
}
␌
osl::CArray<MultiInt, 180> osl::eval::ml::RookPawnY::table;
osl::CArray<MultiInt, 1620> osl::eval::ml::
RookPawnY::y_attack_table;
osl::CArray<MultiInt, 1620> osl::eval::ml::
RookPawnY::y_defense_table;
void osl::eval::ml::
RookPawnYX::setUp(const Weights &weights)
{
for (int i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
{
RookPawnY::y_attack_table[i][s] = weights.value(i + ONE_DIM * 2 * s);
RookPawnY::y_defense_table[i][s] = weights.value(i + ONE_DIM * 2 * s + ONE_DIM);
}
}
}
void osl::eval::ml::
RookPawnY::setUp(const Weights &weights)
{
for (int i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
table[i][s] = weights.value(i + ONE_DIM*s);
}
}
MultiInt osl::eval::ml::
RookPawnY::eval(const NumEffectState &state,
const CArray2d<int, 2, 9> &pawns)
{
MultiInt result;
const CArray<Square,2> kings = {
state.kingSquare<BLACK>(),
state.kingSquare<WHITE>(),
};
for (int i = PtypeTraits<ROOK>::indexMin;
i < PtypeTraits<ROOK>::indexLimit;
++i)
{
const Piece piece = state.pieceOf(i);
if (piece.isOnBoard())
{
if (piece.owner() == BLACK)
{
const int pawn_y =
pawns[BLACK][piece.square().x() - 1];
result +=
table[index(piece, pawn_y)] +
y_attack_table[indexY(kings[WHITE], piece, pawn_y)] +
y_defense_table[indexY(kings[BLACK], piece, pawn_y)];
}
else
{
int y = pawns[WHITE][piece.square().x() - 1];
if (y != 0)
y = 10 - y;
result -=
table[index(piece, y)] +
y_attack_table[indexY(kings[BLACK], piece, y)] +
y_defense_table[indexY(kings[WHITE], piece, y)];
}
}
}
return result;
}
␌
MultiInt osl::eval::ml::AllMajor::weight;
void osl::eval::ml::
AllMajor::setUp(const Weights &weights,int stage)
{
weight[stage] = weights.value(0);
}
␌
template <bool Opening>
osl::CArray<int, 32> osl::eval::ml::MajorGoldSilverAttacked<Opening>::table;
template <bool Opening>
void osl::eval::ml::
MajorGoldSilverAttacked<Opening>::setUp(const Weights &weights)
{
for (size_t i = 0; i < weights.dimension(); ++i)
{
table[i] = weights.value(i);
}
}
template <bool Opening>
int osl::eval::ml::
MajorGoldSilverAttacked<Opening>::index(
const NumEffectState &state, Piece piece)
{
return piece.ptype() + (state.turn() == piece.owner() ? 0 : PTYPE_SIZE);
}
template <bool Opening>
template <osl::Ptype PTYPE>
int osl::eval::ml::
MajorGoldSilverAttacked<Opening>::evalOne(const NumEffectState &state)
{
int result = 0;
for (int i = PtypeTraits<PTYPE>::indexMin;
i < PtypeTraits<PTYPE>::indexLimit;
++i)
{
const Piece piece = state.pieceOf(i);
if (piece.isOnBoard() &&
state.hasEffectAt(alt(piece.owner()), piece.square()))
{
const int weight = table[index(state, piece)];
if (piece.owner() == BLACK)
result += weight;
else
result -= weight;
}
}
return result;
}
template <bool Opening>
int osl::eval::ml::
MajorGoldSilverAttacked<Opening>::eval(const NumEffectState &state)
{
int result = 0;
result += evalOne<ROOK>(state);
result += evalOne<BISHOP>(state);
result += evalOne<GOLD>(state);
result += evalOne<SILVER>(state);
return result;
}
␌
osl::CArray<MultiInt, 612> osl::eval::ml::RookEffectBase::attack_table;
osl::CArray<MultiInt, 612> osl::eval::ml::RookEffectBase::defense_table;
osl::CArray<MultiInt, 32> osl::eval::ml::RookEffectBase::piece_table;
osl::CArray<MultiInt, 23104> osl::eval::ml::RookEffectBase::attack_u;
osl::CArray<MultiInt, 23104> osl::eval::ml::RookEffectBase::attack_d;
osl::CArray<MultiInt, 23104> osl::eval::ml::RookEffectBase::attack_r;
osl::CArray<MultiInt, 23104> osl::eval::ml::RookEffectBase::attack_l;
osl::CArray<MultiInt, 23104> osl::eval::ml::RookEffectBase::defense_u;
osl::CArray<MultiInt, 23104> osl::eval::ml::RookEffectBase::defense_d;
osl::CArray<MultiInt, 23104> osl::eval::ml::RookEffectBase::defense_r;
osl::CArray<MultiInt, 23104> osl::eval::ml::RookEffectBase::defense_l;
osl::CArray<MultiInt, 722> osl::eval::ml::RookEffectBase::attack_nospace;
osl::CArray<MultiInt, 722> osl::eval::ml::RookEffectBase::defense_nospace;
template<osl::Player P>
inline
MultiInt osl::eval::ml::RookEffectBase::evalOne(
const NumEffectState& state,
Square rook,
Square myKing,
Square opKing,
Square up,
Square dp,
Square rp,
Square lp,
bool isP)
{
MultiInt result;
PtypeO uPtypeO=state.pieceAt(up).ptypeO();
PtypeO dPtypeO=state.pieceAt(dp).ptypeO();
PtypeO rPtypeO=state.pieceAt(rp).ptypeO();
PtypeO lPtypeO=state.pieceAt(lp).ptypeO();
if(P==WHITE){
uPtypeO=(PtypeO)(static_cast<int>(uPtypeO)^(~15));
dPtypeO=(PtypeO)(static_cast<int>(dPtypeO)^(~15));
rPtypeO=(PtypeO)(static_cast<int>(rPtypeO)^(~15));
lPtypeO=(PtypeO)(static_cast<int>(lPtypeO)^(~15));
up=up.rotate180EdgeOK();
dp=dp.rotate180EdgeOK();
rp=rp.rotate180EdgeOK();
lp=lp.rotate180EdgeOK();
rook=rook.rotate180();
myKing=myKing.rotate180();
opKing=opKing.rotate180();
}
assert((myKing.y()-dp.y())<(myKing.y()-up.y()));
assert((myKing.x()-lp.x())<(myKing.x()-rp.x()));
result+=attack_u[index1(opKing,up,uPtypeO,isP)]+
attack_d[index1(opKing,dp,dPtypeO,isP)]+
attack_l[index1(opKing,lp,lPtypeO,isP)]+
attack_r[index1(opKing,rp,rPtypeO,isP)]+
defense_u[index1(myKing,up,uPtypeO,isP)]+
defense_d[index1(myKing,dp,dPtypeO,isP)]+
defense_l[index1(myKing,lp,lPtypeO,isP)]+
defense_r[index1(myKing,rp,rPtypeO,isP)]+
attack_nospace[index2(opKing,rook,isP)]+
defense_nospace[index2(myKing,rook,isP)];
return result;
}
MultiInt osl::eval::ml::
RookEffectBase::eval(const NumEffectState &state)
{
const CArray<Square,2> kings = {
state.kingSquare(BLACK),
state.kingSquare(WHITE),
};
MultiInt result;
for (int i = PtypeTraits<ROOK>::indexMin; i < PtypeTraits<ROOK>::indexLimit;
++i)
{
const Piece p = state.pieceOf(i);
if (! p.isOnBoard()) continue;
const Square pos=p.square();
Square up=state.mobilityOf(U,i);
Square dp=state.mobilityOf(D,i);
Square lp=state.mobilityOf(L,i);
Square rp=state.mobilityOf(R,i);
const bool isP=p.isPromoted();
if(p.owner()==BLACK)
result+=evalOne<BLACK>(state,pos,kings[0],kings[1],up,dp,rp,lp,isP);
else
result-=evalOne<WHITE>(state,pos,kings[1],kings[0],dp,up,lp,rp,isP);
}
return result;
}
void osl::eval::ml::RookEffect::setUp(const Weights &weights,int stage)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
attack_table[i][stage] = weights.value(i);
defense_table[i][stage] = weights.value(i + ONE_DIM);
}
}
void osl::eval::ml::RookEffectPiece::setUp(const Weights &weights)
{
for (size_t i = 0; i < 32; ++i)
{
for (int s=0; s<NStages; ++s)
RookEffectBase::piece_table[i][s] = weights.value(i + 32*s);
}
}
void osl::eval::ml::
RookEffectPieceKingRelative::setUp(const Weights &weights)
{
CArray<MultiInt, 19584> piece_attack_table;
CArray<MultiInt, 19584> piece_defense_table;
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
{
piece_attack_table[i][s] = weights.value(i + ONE_DIM*2*s);
piece_defense_table[i][s] = weights.value(i + ONE_DIM*2*s + ONE_DIM);
}
}
for(int isP=0;isP<2;isP++)
for(int y_diff=-9;y_diff<=9;y_diff++)
for(int x_diff= -9;x_diff<=9;x_diff++){
int i2=index2(x_diff,y_diff,isP);
if(abs(x_diff)<9 && abs(y_diff)<9){
attack_nospace[i2]=
-(attack_table[index(abs(x_diff),y_diff,true,isP)]+
attack_table[index(abs(x_diff),y_diff,false,isP)]);
defense_nospace[i2]=
-(defense_table[index(abs(x_diff),y_diff,true,isP)]+
defense_table[index(abs(x_diff),y_diff,false,isP)]);
}
for(int ptypeo= PTYPEO_MIN;ptypeo<=PTYPEO_MAX;ptypeo++){
if(getPtype((PtypeO)ptypeo)==(int)PTYPE_EMPTY) continue;
int i1=index1(x_diff,y_diff,(PtypeO)ptypeo,isP);
int indexPieceH,indexPieceV;
int table_ptypeo=ptypeo;
if(getPtype((PtypeO)ptypeo)==PTYPE_EDGE) table_ptypeo=PTYPEO_EDGE;
if(getPtype((PtypeO)ptypeo)==PTYPE_EDGE || abs(x_diff)==9 || abs(y_diff)==9){
indexPieceH= 0+0+(PTYPEO_EDGE-PTYPEO_MIN)*17*9+4896+isP*9792;
indexPieceV= 0+0+(PTYPEO_EDGE-PTYPEO_MIN)*17*9+ isP*9792;
}
else{
indexPieceH= index0(abs(x_diff),-y_diff,(PtypeO)ptypeo,true,isP);
indexPieceV= index0(abs(x_diff),-y_diff,(PtypeO)ptypeo,false,isP);
}
attack_u[i1]=piece_attack_table[indexPieceV]+piece_table[table_ptypeo-PTYPEO_MIN];
defense_u[i1]=piece_defense_table[indexPieceV];
attack_d[i1]=piece_attack_table[indexPieceV]+piece_table[table_ptypeo-PTYPEO_MIN];
defense_d[i1]=piece_defense_table[indexPieceV];
if(abs(x_diff)<=8){
for(int y_diff_1=y_diff+1;y_diff_1<=8;y_diff_1++){
int i=index(abs(x_diff),y_diff_1,false,isP);
attack_u[i1]+=attack_table[i];
defense_u[i1]+=defense_table[i];
}
for(int y_diff_1=std::max(-8,y_diff);y_diff_1<=8;y_diff_1++){
int i=index(abs(x_diff),y_diff_1,false,isP);
attack_d[i1]-=attack_table[i];
defense_d[i1]-=defense_table[i];
}
}
attack_l[i1]=piece_attack_table[indexPieceH]+piece_table[table_ptypeo-PTYPEO_MIN];
defense_l[i1]=piece_defense_table[indexPieceH];
attack_r[i1]=piece_attack_table[indexPieceH]+piece_table[table_ptypeo-PTYPEO_MIN];
defense_r[i1]=piece_defense_table[indexPieceH];
if(abs(y_diff)<=8){
for(int x_diff_1=x_diff+1;x_diff_1<=8;x_diff_1++){
int i=index(abs(x_diff_1),y_diff,true,isP);
attack_r[i1]+=attack_table[i];
defense_r[i1]+=defense_table[i];
}
for(int x_diff_1=std::max(-8,x_diff);x_diff_1<=8;x_diff_1++){
int i=index(abs(x_diff_1),y_diff,true,isP);
attack_l[i1]-=attack_table[i];
defense_l[i1]-=defense_table[i];
}
}
}
}
}
␌
osl::CArray<MultiInt, 256> osl::eval::ml::RookPromoteDefense::promote_defense_table;
osl::CArray<MultiInt, 144> osl::eval::ml::RookPromoteDefense::promote_defense_rook_table;
void osl::eval::ml::RookPromoteDefense::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
promote_defense_table[i][s] = weights.value(i + ONE_DIM*s);
}
}
void osl::eval::ml::RookPromoteDefenseRookH::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
RookPromoteDefense::promote_defense_rook_table[i][s] =
weights.value(i + ONE_DIM*s);
}
}
MultiInt osl::eval::ml::
RookPromoteDefense::eval(const NumEffectState &state)
{
MultiInt result;
for (int i = PtypeTraits<ROOK>::indexMin;
i < PtypeTraits<ROOK>::indexLimit;
++i){
const Piece rook = state.pieceOf(i);
if(rook.isOnBoardNotPromoted()){
if(rook.owner()==BLACK){
Square rookPos=rook.square();
if(rookPos.y()>=4){
Square pos=state.mobilityOf(U,i);
const Piece attacked = state.pieceAt(pos);
if (attacked.canMoveOn<BLACK>()){
const NumBitmapEffect effect = state.effectSetAt(pos);
if (effect.countEffect(WHITE) == 1){
PieceMask mask = effect & state.piecesOnBoard(WHITE);
const Piece effect_piece = state.pieceOf(mask.takeOneBit());
const int index = attacked.ptype() * 16 + effect_piece.ptype();
result += promote_defense_table[index];
if (effect_piece.ptype() == ROOK &&
effect_piece.square().x() != rookPos.x())
{
result +=
promote_defense_rook_table[
attacked.ptype() * 9 +
mobility::RookMobility::countHorizontalAll<BLACK>(state,
rook)];
}
}
}
}
}
else{
Square rookPos=rook.square();
if(rookPos.y()<=6){
Square pos=state.mobilityOf(D,i);
const Piece attacked = state.pieceAt(pos);
if (attacked.canMoveOn<WHITE>()){
const NumBitmapEffect effect = state.effectSetAt(pos);
if (effect.countEffect(BLACK) == 1){
PieceMask mask = effect & state.piecesOnBoard(BLACK);
const Piece effect_piece = state.pieceOf(mask.takeOneBit());
const int index = attacked.ptype() * 16 + effect_piece.ptype();
result -= promote_defense_table[index];
if (effect_piece.ptype() == ROOK &&
effect_piece.square().x() != rookPos.x())
{
result -=
promote_defense_rook_table[
attacked.ptype() * 9 +
mobility::RookMobility::countHorizontalAll<WHITE>(state,
rook)];
}
}
}
}
}
}
}
return result;
}
␌
osl::CArray<MultiInt, 612> osl::eval::ml::BishopEffectBase::attack_table;
osl::CArray<MultiInt, 612> osl::eval::ml::BishopEffectBase::defense_table;
osl::CArray<MultiInt, 32> osl::eval::ml::BishopEffectBase::piece_table;
osl::CArray<MultiInt, 23104> osl::eval::ml::BishopEffectBase::attack_ul;
osl::CArray<MultiInt, 23104> osl::eval::ml::BishopEffectBase::attack_ur;
osl::CArray<MultiInt, 23104> osl::eval::ml::BishopEffectBase::attack_dl;
osl::CArray<MultiInt, 23104> osl::eval::ml::BishopEffectBase::attack_dr;
osl::CArray<MultiInt, 23104> osl::eval::ml::BishopEffectBase::defense_ul;
osl::CArray<MultiInt, 23104> osl::eval::ml::BishopEffectBase::defense_ur;
osl::CArray<MultiInt, 23104> osl::eval::ml::BishopEffectBase::defense_dl;
osl::CArray<MultiInt, 23104> osl::eval::ml::BishopEffectBase::defense_dr;
osl::CArray<MultiInt, 722> osl::eval::ml::BishopEffectBase::attack_nospace;
osl::CArray<MultiInt, 722> osl::eval::ml::BishopEffectBase::defense_nospace;
template<osl::Player P>
inline
MultiInt osl::eval::ml::BishopEffectBase::evalOne(
const NumEffectState& state,
Square bishop,
Square myKing,
Square opKing,
Square ulp,
Square urp,
Square dlp,
Square drp,
bool isP)
{
MultiInt result;
PtypeO ulPtypeO=state.pieceAt(ulp).ptypeO();
PtypeO urPtypeO=state.pieceAt(urp).ptypeO();
PtypeO dlPtypeO=state.pieceAt(dlp).ptypeO();
PtypeO drPtypeO=state.pieceAt(drp).ptypeO();
if(P==WHITE){
ulPtypeO=(PtypeO)(static_cast<int>(ulPtypeO)^(~15));
urPtypeO=(PtypeO)(static_cast<int>(urPtypeO)^(~15));
dlPtypeO=(PtypeO)(static_cast<int>(dlPtypeO)^(~15));
drPtypeO=(PtypeO)(static_cast<int>(drPtypeO)^(~15));
ulp=ulp.rotate180EdgeOK();
urp=urp.rotate180EdgeOK();
dlp=dlp.rotate180EdgeOK();
drp=drp.rotate180EdgeOK();
bishop=bishop.rotate180();
myKing=myKing.rotate180();
opKing=opKing.rotate180();
}
result+=attack_ul[index1(opKing,ulp,ulPtypeO,isP)]+
attack_ur[index1(opKing,urp,urPtypeO,isP)]+
attack_dl[index1(opKing,dlp,dlPtypeO,isP)]+
attack_dr[index1(opKing,drp,drPtypeO,isP)]+
defense_ul[index1(myKing,ulp,ulPtypeO,isP)]+
defense_ur[index1(myKing,urp,urPtypeO,isP)]+
defense_dl[index1(myKing,dlp,dlPtypeO,isP)]+
defense_dr[index1(myKing,drp,drPtypeO,isP)]+
attack_nospace[index2(opKing,bishop,isP)]+
defense_nospace[index2(myKing,bishop,isP)];
return result;
}
MultiInt osl::eval::ml::
BishopEffectBase::eval(const NumEffectState &state)
{
const CArray<Square,2> kings = {{
state.kingSquare(BLACK),
state.kingSquare(WHITE),
}};
MultiInt result;
for (int i = PtypeTraits<BISHOP>::indexMin; i < PtypeTraits<BISHOP>::indexLimit;
++i)
{
const Piece p = state.pieceOf(i);
if (! p.isOnBoard()) continue;
const Square pos=p.square();
Square ulp=state.mobilityOf(UL,i);
Square urp=state.mobilityOf(UR,i);
Square dlp=state.mobilityOf(DL,i);
Square drp=state.mobilityOf(DR,i);
const bool isP=p.isPromoted();
if(p.owner()==BLACK)
result+=evalOne<BLACK>(state,pos,kings[0],kings[1],ulp,urp,dlp,drp,isP);
else
result-=evalOne<WHITE>(state,pos,kings[1],kings[0],drp,dlp,urp,ulp,isP);
}
return result;
}
void osl::eval::ml::BishopEffect::setUp(const Weights &weights,int stage)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
attack_table[i][stage] = weights.value(i);
defense_table[i][stage] = weights.value(i + ONE_DIM);
}
}
void osl::eval::ml::BishopEffectPiece::setUp(const Weights &weights)
{
for (size_t i = 0; i < 32; ++i)
{
for (int s=0; s<NStages; ++s)
BishopEffectBase::piece_table[i][s] = weights.value(i + 32*s);
}
}
void osl::eval::ml::
BishopEffectPieceKingRelative::setUp(const Weights &weights)
{
CArray<MultiInt, 19584> piece_attack_table;
CArray<MultiInt, 19584> piece_defense_table;
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
{
piece_attack_table[i][s] = weights.value(i + ONE_DIM * 2 * s);
piece_defense_table[i][s] = weights.value(i + ONE_DIM * 2 * s + ONE_DIM);
}
}
for(int isP=0;isP<2;isP++)
for(int y_diff=-9;y_diff<=9;y_diff++)
for(int x_diff= -9;x_diff<=9;x_diff++){
int i2=index2(x_diff,y_diff,isP);
if(abs(x_diff)<9 && abs(y_diff)<9){
attack_nospace[i2]=
-(attack_table[index(x_diff,y_diff,true,isP)]+
attack_table[index(x_diff,y_diff,false,isP)]);
defense_nospace[i2]=
-(defense_table[index(x_diff,y_diff,true,isP)]+
defense_table[index(x_diff,y_diff,false,isP)]);
}
for(int ptypeo= PTYPEO_MIN;ptypeo<=PTYPEO_MAX;ptypeo++){
if(getPtype((PtypeO)ptypeo)==(int)PTYPE_EMPTY) continue;
int i1=index1(x_diff,y_diff,(PtypeO)ptypeo,isP);
int indexPieceUR,indexPieceUL;
int table_ptypeo=ptypeo;
if(getPtype((PtypeO)ptypeo)==PTYPE_EDGE) table_ptypeo=PTYPEO_EDGE;
if(getPtype((PtypeO)ptypeo)==PTYPE_EDGE || abs(x_diff)==9 || abs(y_diff)==9){
indexPieceUR= 0+0+(PTYPEO_EDGE-PTYPEO_MIN)*17*9+4896+isP*9792;
indexPieceUL= 0+0+(PTYPEO_EDGE-PTYPEO_MIN)*17*9+ isP*9792;
}
else{
indexPieceUR= index0(x_diff,y_diff,(PtypeO)ptypeo,true,isP);
indexPieceUL= index0(x_diff,y_diff,(PtypeO)ptypeo,false,isP);
}
attack_ul[i1]=piece_attack_table[indexPieceUL]+piece_table[table_ptypeo-PTYPEO_MIN];
defense_ul[i1]=piece_defense_table[indexPieceUL];
attack_dr[i1]=piece_attack_table[indexPieceUL]+piece_table[table_ptypeo-PTYPEO_MIN];
defense_dr[i1]=piece_defense_table[indexPieceUL];
{
int y_diff_1=y_diff+1, x_diff_1=x_diff-1;
for(;y_diff_1<=8 && x_diff_1>=-8;y_diff_1++,x_diff_1--){
if(std::abs(x_diff_1)<=8 && std::abs(y_diff_1)<=8){
int i=index(x_diff_1,y_diff_1,false,isP);
attack_ul[i1]+=attack_table[i];
defense_ul[i1]+=defense_table[i];
}
}
}
{
int y_diff_1=y_diff, x_diff_1=x_diff;
for(;y_diff_1<=8 && x_diff_1>=-8;y_diff_1++,x_diff_1--){
if(std::abs(x_diff_1)<=8 && std::abs(y_diff_1)<=8){
int i=index(x_diff_1,y_diff_1,false,isP);
attack_dr[i1]-=attack_table[i];
defense_dr[i1]-=defense_table[i];
}
}
}
attack_ur[i1]=piece_attack_table[indexPieceUR]+piece_table[table_ptypeo-PTYPEO_MIN];
defense_ur[i1]=piece_defense_table[indexPieceUR];
attack_dl[i1]=piece_attack_table[indexPieceUR]+piece_table[table_ptypeo-PTYPEO_MIN];
defense_dl[i1]=piece_defense_table[indexPieceUR];
{
int y_diff_1=y_diff+1, x_diff_1=x_diff+1;
for(;y_diff_1<=8 && x_diff_1<=8;y_diff_1++,x_diff_1++){
if(std::abs(x_diff_1)<=8 && std::abs(y_diff_1)<=8){
int i=index(x_diff_1,y_diff_1,true,isP);
attack_ur[i1]+=attack_table[i];
defense_ur[i1]+=defense_table[i];
}
}
}
{
int y_diff_1=y_diff, x_diff_1=x_diff;
for(;y_diff_1<=8 && x_diff_1<=8;y_diff_1++,x_diff_1++){
if(std::abs(x_diff_1)<=8 && std::abs(y_diff_1)<=8){
int i=index(x_diff_1,y_diff_1,true,isP);
attack_dl[i1]-=attack_table[i];
defense_dl[i1]-=defense_table[i];
}
}
}
}
}
}
␌
osl::CArray<MultiInt, 32> osl::eval::ml::BishopHead::table;
osl::CArray<MultiInt, 4896> osl::eval::ml::BishopHead::king_table;
osl::CArray<MultiInt, 160> osl::eval::ml::BishopHead::x_table;
void osl::eval::ml::BishopHead::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
table[i][s] = weights.value(i + ONE_DIM*s);
}
}
void osl::eval::ml::
BishopHeadKingRelative::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
BishopHead::king_table[i][s] = weights.value(i + ONE_DIM*s);
}
for(int x_diff=0;x_diff<=8;x_diff++)
for(int y_diff=-8;y_diff<=8;y_diff++){
for(int i=0;i<32;i++)
BishopHead::king_table[(i*9+x_diff)*17+y_diff+8]+=BishopHead::table[i];
}
const PtypeO PTYPEO_EMPTY_R=newPtypeO(WHITE,PTYPE_EMPTY);
const PtypeO PTYPEO_EDGE_R=newPtypeO(BLACK,PTYPE_EDGE);
for(int x_diff=0;x_diff<=8;x_diff++)
for(int y_diff=-8;y_diff<=8;y_diff++){
BishopHead::king_table[(ptypeOIndex(PTYPEO_EMPTY_R)*9+x_diff)*17+y_diff+8]=
BishopHead::king_table[(ptypeOIndex(PTYPEO_EMPTY)*9+x_diff)*17+y_diff+8];
BishopHead::king_table[(ptypeOIndex(PTYPEO_EDGE_R)*9+x_diff)*17+y_diff+8]=
BishopHead::king_table[(ptypeOIndex(PTYPEO_EDGE)*9+x_diff)*17+y_diff+8];
}
}
void osl::eval::ml::BishopHeadX::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
BishopHead::x_table[i][s] = weights.value(i + ONE_DIM*s);
}
}
MultiInt osl::eval::ml::
BishopHead::eval(const NumEffectState &state)
{
MultiInt result;
for (int i = PtypeTraits<BISHOP>::indexMin;
i < PtypeTraits<BISHOP>::indexLimit;
++i){
const Piece p = state.pieceOf(i);
if (p.isOnBoardNotPromoted()){
const Square pos=p.square();
if (p.owner() == BLACK){
if(pos.y()>=2){
const Square up = pos+DirectionPlayerTraits<U,BLACK>::offset();
if (!state.hasEffectAt(BLACK, up)){
const Square king = state.kingSquare(BLACK);
const PtypeO ptypeo = state.pieceAt(up).ptypeO();
const int index_k = indexK(BLACK, ptypeo,
std::abs(pos.x() - king.x()),
pos.y() - king.y());
result += king_table[index_k];
result += x_table[indexX<BLACK>(ptypeo, pos.x())];
}
}
}
else if(pos.y()<=8) {
const Square up = pos+DirectionPlayerTraits<U,WHITE>::offset();
if (!state.hasEffectAt(WHITE, up)){
const Square king = state.kingSquare(WHITE);
const PtypeO ptypeo = state.pieceAt(up).ptypeO();
const int index_k = indexK(WHITE, ptypeo,
std::abs(pos.x() - king.x()),
pos.y() - king.y());
result -= king_table[index_k];
result -= x_table[indexX<WHITE>(ptypeo, pos.x())];
}
}
}
}
return result;
}
␌
osl::CArray<MultiInt, 374544> osl::eval::ml::KingRookBishop::table;
void osl::eval::ml::KingRookBishop::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
table[i][s] = weights.value(i + ONE_DIM*s);
}
}
template<osl::Player P>
MultiInt osl::eval::ml::
KingRookBishop::evalOne(const NumEffectState &state)
{
const Square king=state.kingSquare(P);
MultiInt result;
for (int i = PtypeTraits<ROOK>::indexMin;
i < PtypeTraits<ROOK>::indexLimit;
++i)
{
const Piece rook = state.pieceOf(i);
if (!rook.isOnBoard())
{
continue;
}
for (int j = PtypeTraits<BISHOP>::indexMin;
j < PtypeTraits<BISHOP>::indexLimit;
++j)
{
const Piece bishop = state.pieceOf(j);
if (!bishop.isOnBoard())
{
continue;
}
result += table[index<P>(king, rook, bishop)];
}
}
return result;
}
MultiInt osl::eval::ml::
KingRookBishop::eval(const NumEffectState &state)
{
return evalOne<BLACK>(state)-evalOne<WHITE>(state);
}
␌
osl::CArray<MultiInt, 9> osl::eval::ml::NumPiecesBetweenBishopAndKing::self_table;
osl::CArray<MultiInt, 9> osl::eval::ml::NumPiecesBetweenBishopAndKing::opp_table;
osl::CArray<MultiInt, 9> osl::eval::ml::NumPiecesBetweenBishopAndKing::all_table;
void osl::eval::ml::
NumPiecesBetweenBishopAndKingSelf::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
NumPiecesBetweenBishopAndKing::self_table[i][s] =
weights.value(i + ONE_DIM*s);
}
}
void osl::eval::ml::
NumPiecesBetweenBishopAndKingOpp::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
NumPiecesBetweenBishopAndKing::opp_table[i][s] =
weights.value(i + ONE_DIM*s);
}
}
void osl::eval::ml::
NumPiecesBetweenBishopAndKingAll::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
NumPiecesBetweenBishopAndKing::all_table[i][s] =
weights.value(i + ONE_DIM*s);
}
}
osl::MultiInt osl::eval::ml::
NumPiecesBetweenBishopAndKing::eval(const NumEffectState &state)
{
MultiInt result;
for (int i = PtypeTraits<BISHOP>::indexMin;
i < PtypeTraits<BISHOP>::indexLimit;
++i)
{
const Piece bishop = state.pieceOf(i);
if (!bishop.isOnBoard())
{
continue;
}
int self, opp, all;
countBetween(state,
state.kingSquare(alt(bishop.owner())),
bishop, self, opp, all);
if (bishop.owner() == BLACK)
{
result += (self_table[self] + opp_table[opp] + all_table[all]);
}
else
{
result -= (self_table[self] + opp_table[opp] + all_table[all]);
}
}
return result;
}
void osl::eval::ml::
NumPiecesBetweenBishopAndKing::countBetween(
const NumEffectState &state, Square king, Piece bishop,
int &self_count, int &opp_count, int &total_count)
{
assert(bishop.isOnBoard());
if ((king.x() + king.y() != bishop.square().x() + bishop.square().y()) &&
(king.x() - king.y() != bishop.square().x() - bishop.square().y()))
{
self_count = opp_count = total_count = 8;
return;
}
Direction dir;
assert(king.x() != bishop.square().x());
assert(king.y() != bishop.square().y());
if (king.x() < bishop.square().x())
{
if (king.y() < bishop.square().y())
{
dir = UR;
}
else
{
dir = DR;
}
}
else
{
if (king.y() < bishop.square().y())
{
dir = UL;
}
else
{
dir = DL;
}
}
const Player player = bishop.owner();
const Direction move_dir = (player == BLACK ? dir : inverse(dir));
self_count = opp_count = total_count = 0;
for (Square pos = state.mobilityOf(dir, bishop.number());
pos != king; pos = Board_Table.nextSquare(player, pos, move_dir))
{
assert(pos.isOnBoard());
const Piece piece = state.pieceAt(pos);
if (!piece.isEmpty())
{
++total_count;
if (piece.owner() == player)
++self_count;
else
++opp_count;
}
}
}
␌
osl::CArray<MultiInt, 64>
osl::eval::ml::BishopBishopPiece::table;
void osl::eval::ml::
BishopBishopPiece::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
table[i][s] = weights.value(i + ONE_DIM*s);
}
}
osl::MultiInt osl::eval::ml::
BishopBishopPiece::eval(const NumEffectState &state)
{
MultiInt result;
const Piece bishop1 = state.pieceOf(PtypeTraits<BISHOP>::indexMin);
const Piece bishop2 = state.pieceOf(PtypeTraits<BISHOP>::indexMin + 1);
if (!bishop1.isOnBoard() || !bishop2.isOnBoard() ||
bishop1.owner() == bishop2.owner())
return result;
if (bishop1.square().x() + bishop1.square().y() !=
bishop2.square().x() + bishop2.square().y() &&
bishop1.square().x() - bishop1.square().y() !=
bishop2.square().x() - bishop2.square().y())
return result;
if (state.hasEffectByPtype<BISHOP>(bishop2.owner(), bishop1.square()))
return result;
Direction dir;
if (bishop1.square().x() < bishop2.square().x())
{
if (bishop1.square().y() < bishop2.square().y())
{
dir = UR;
}
else
{
dir = DR;
}
}
else
{
if (bishop1.square().y() < bishop2.square().y())
{
dir = UL;
}
else
{
dir = DL;
}
}
Square p1 = state.mobilityOf(inverse(dir), bishop1.number());
Square p2 = state.mobilityOf(dir, bishop2.number());
if (p1 == p2)
{
const Piece p = state.pieceAt(p1);
const bool black_with_support =
state.hasEffectAt<BLACK>(bishop1.owner() == BLACK ?
bishop1.square() : bishop2.square());
const bool white_with_support =
state.hasEffectAt<WHITE>(bishop1.owner() == WHITE ?
bishop1.square() : bishop2.square());
if (p.owner() == BLACK)
{
result += table[index(p.ptype(), black_with_support,
white_with_support)];
}
else
{
result -= table[index(p.ptype(), white_with_support,
black_with_support)];
}
}
return result;
}
␌
osl::CArray<MultiInt, 800>
osl::eval::ml::RookRook::table;
void osl::eval::ml::
RookRook::setUp(const Weights &weights)
{
CArray<MultiInt, 800> orig_table;
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
orig_table[i][s] = weights.value(i + ONE_DIM*s);
}
for (int owner = 0; owner < 2; ++owner)
{
const bool same_player = (owner == 0);
for (int y1 = 0; y1 < 10; ++y1)
{
for (int y2 = 0; y2 < 10; ++y2)
{
for (int promoted1 = 0; promoted1 < 2; ++promoted1)
{
for (int promoted2 = 0; promoted2 < 2; ++promoted2)
{
if (same_player)
{
int y1p = y1;
int y2p = y2;
int promoted1p = promoted1;
int promoted2p = promoted2;
if (y1 > y2 || (y1 == y2 && !promoted1 && promoted2))
{
std::swap(y1p, y2p);
std::swap(promoted1p, promoted2p);
}
table[index(same_player, promoted1, promoted2,
y1, y2)] =
orig_table[index(same_player, promoted1p, promoted2p,
y1p, y2p)];
}
else
{
if (y1 + y2 > 10 || y1 == 0 ||
(y1 + y2 == 10 && promoted1))
{
const int idx = index(same_player, promoted1, promoted2,
y1, y2);
table[idx] = orig_table[idx];
}
else
{
table[index(same_player, promoted1, promoted2,
y1, y2)] =
-orig_table[index(same_player, promoted2, promoted1,
(10 - y2) % 10, (10 - y1) % 10)];
}
}
}
}
}
}
}
}
osl::MultiInt osl::eval::ml::
RookRook::eval(const NumEffectState &state)
{
MultiInt result;
Piece rook1 = state.pieceOf(PtypeTraits<ROOK>::indexMin);
Piece rook2 = state.pieceOf(PtypeTraits<ROOK>::indexMin + 1);
if (rook1.owner() == rook2.owner())
{
if (rook1.owner() == BLACK)
{
result += table[index<true, BLACK>(rook1, rook2)];
}
else
{
result -= table[index<true, WHITE>(rook1, rook2)];
}
}
else
{
if (rook1.owner() != BLACK)
{
std::swap(rook1, rook2);
}
result += table[index<false, BLACK>(rook1, rook2)];
}
return result;
}
␌
osl::CArray<MultiInt, 128>
osl::eval::ml::RookRookPiece::table;
void osl::eval::ml::
RookRookPiece::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
table[i][s] = weights.value(i + ONE_DIM*s);
}
}
osl::MultiInt osl::eval::ml::
RookRookPiece::eval(const NumEffectState &state)
{
MultiInt result;
const Piece rook1 = state.pieceOf(PtypeTraits<ROOK>::indexMin);
const Piece rook2 = state.pieceOf(PtypeTraits<ROOK>::indexMin + 1);
if (!rook1.isOnBoard() || !rook2.isOnBoard() ||
rook1.owner() == rook2.owner())
return result;
if (state.hasEffectByPtype<ROOK>(rook2.owner(), rook1.square()))
return result;
Direction dir;
bool vertical = false;
if (rook1.square().x() == rook2.square().x())
{
vertical = true;
if (rook1.square().y() < rook2.square().y())
{
dir = D;
}
else
{
dir = U;
}
}
else if (rook1.square().y() == rook2.square().y())
{
if (rook1.square().x() < rook2.square().x())
{
dir = L;
}
else
{
dir = R;
}
}
else
{
return result;
}
Square p1 = state.mobilityOf(dir, rook1.number());
Square p2 = state.mobilityOf(inverse(dir), rook2.number());
assert(p1.isOnBoard() && p2.isOnBoard());
if (p1 == p2)
{
const Piece p = state.pieceAt(p1);
const bool black_with_support =
state.hasEffectAt<BLACK>(rook1.owner() == BLACK ?
rook1.square() : rook2.square());
const bool white_with_support =
state.hasEffectAt<WHITE>(rook1.owner() == WHITE ?
rook1.square() : rook2.square());
if (p.owner() == BLACK)
{
result += table[index(p.ptype(), black_with_support,
white_with_support, vertical)];
}
else
{
result -= table[index(p.ptype(), white_with_support,
black_with_support, vertical)];
}
}
return result;
}
␌
osl::CArray<MultiInt, 32>
osl::eval::ml::BishopStandFile5::table;
void osl::eval::ml::
BishopStandFile5::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
table[i][s] = weights.value(i + ONE_DIM*s);
}
}
osl::MultiInt osl::eval::ml::
BishopStandFile5::eval(const NumEffectState &state)
{
MultiInt result;
if (state.hasPieceOnStand<BISHOP>(BLACK))
{
result += table[ptypeOIndex(state.pieceAt(Square(5, 3)).ptypeO())];
}
if (state.hasPieceOnStand<BISHOP>(WHITE))
{
PtypeO ptypeO = state.pieceAt(Square(5, 7)).ptypeO();
ptypeO = altIfPiece(ptypeO);
result -= table[ptypeOIndex(ptypeO)];
}
return result;
}
␌
osl::CArray<MultiInt, osl::eval::ml::MajorCheckWithCapture::ONE_DIM>
osl::eval::ml::MajorCheckWithCapture::table;
void osl::eval::ml::
MajorCheckWithCapture::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
table[i][s] = weights.value(i + ONE_DIM*s);
}
}
template <osl::Player Owner>
osl::MultiInt osl::eval::ml::
MajorCheckWithCapture::addOne(const NumEffectState &state)
{
const Square king = state.kingSquare(Owner);
PieceMask pieces = state.effectedMask(alt(Owner));
pieces &= state.piecesOnBoard(Owner);
pieces &= ~state.effectedMask(Owner);
MultiInt sum;
while (pieces.any()) {
const Piece p = state.pieceOf(pieces.takeOneBit());
const Square sq = p.square();
if (state.hasLongEffectAt<ROOK>(alt(Owner), sq)
&& state.hasEffectIf(newPtypeO(BLACK,ROOK), sq, king)) {
if (Owner == BLACK)
sum += table[index(p.ptype(), true, sq.canPromote(alt(Owner)))];
else
sum -= table[index(p.ptype(), true, sq.canPromote(alt(Owner)))];
}
if (state.hasLongEffectAt<BISHOP>(alt(Owner), sq)
&& state.hasEffectIf(newPtypeO(BLACK,BISHOP), sq, king)) {
if (Owner == BLACK)
sum += table[index(p.ptype(), false, sq.canPromote(alt(Owner)))];
else
sum -= table[index(p.ptype(), false, sq.canPromote(alt(Owner)))];
}
}
return sum;
}
osl::MultiInt osl::eval::ml::
MajorCheckWithCapture::eval(const NumEffectState &state)
{
return addOne<BLACK>(state) + addOne<WHITE>(state);
}
␌
osl::CArray<MultiInt, osl::eval::ml::RookSilverKnight::ONE_DIM>
osl::eval::ml::RookSilverKnight::table;
void osl::eval::ml::
RookSilverKnight::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
table[i][s] = weights.value(i + ONE_DIM*s);
}
}
osl::MultiInt osl::eval::ml::
RookSilverKnight::eval(const NumEffectState &state)
{
MultiInt result;
for (int i = PtypeTraits<ROOK>::indexMin;
i < PtypeTraits<ROOK>::indexLimit;
++i)
{
const Piece rook = state.pieceOf(i);
if (!rook.isOnBoard())
{
continue;
}
for (int i = PtypeTraits<SILVER>::indexMin;
i < PtypeTraits<SILVER>::indexLimit;
++i)
{
const Piece silver = state.pieceOf(i);
if (!silver.isOnBoard() || silver.isPromoted() ||
silver.owner() != rook.owner())
{
continue;
}
for (int i = PtypeTraits<KNIGHT>::indexMin;
i < PtypeTraits<KNIGHT>::indexLimit;
++i)
{
const Piece knight = state.pieceOf(i);
if (!knight.isOnBoard() || knight.isPromoted() ||
knight.owner() != rook.owner())
{
continue;
}
if (rook.owner() == BLACK)
{
if (rook.square().x() > 5)
{
result += table[index(9 - rook.square().x(), rook.square().y() - 1,
9 - silver.square().x(), silver.square().y() - 1,
9 - knight.square().x(), knight.square().y() - 1)];
}
else
{
result += table[index(rook.square().x() - 1, rook.square().y() - 1,
silver.square().x() - 1, silver.square().y() - 1,
knight.square().x() - 1, knight.square().y() - 1)];
}
}
else
{
if (rook.square().x() >= 5)
{
result -= table[index(9 - rook.square().x(), 9 - rook.square().y(),
9 - silver.square().x(), 9 - silver.square().y(),
9 - knight.square().x(), 9 - knight.square().y())];
}
else
{
result -= table[index(rook.square().x() - 1, 9 - rook.square().y(),
silver.square().x() - 1, 9 - silver.square().y(),
knight.square().x() - 1, 9 - knight.square().y())];
}
}
}
}
}
return result;
}
␌
osl::CArray<MultiInt, osl::eval::ml::BishopSilverKnight::ONE_DIM>
osl::eval::ml::BishopSilverKnight::table;
void osl::eval::ml::
BishopSilverKnight::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
table[i][s] = weights.value(i + ONE_DIM*s);
}
}
osl::MultiInt osl::eval::ml::
BishopSilverKnight::eval(const NumEffectState &state)
{
MultiInt result;
for (int i = PtypeTraits<BISHOP>::indexMin;
i < PtypeTraits<BISHOP>::indexLimit;
++i)
{
const Piece bishop = state.pieceOf(i);
if (!bishop.isOnBoard())
{
continue;
}
for (int i = PtypeTraits<SILVER>::indexMin;
i < PtypeTraits<SILVER>::indexLimit;
++i)
{
const Piece silver = state.pieceOf(i);
if (!silver.isOnBoard() || silver.isPromoted() ||
silver.owner() != bishop.owner())
{
continue;
}
for (int i = PtypeTraits<KNIGHT>::indexMin;
i < PtypeTraits<KNIGHT>::indexLimit;
++i)
{
const Piece knight = state.pieceOf(i);
if (!knight.isOnBoard() || knight.isPromoted() ||
knight.owner() != bishop.owner())
{
continue;
}
if (bishop.owner() == BLACK)
{
if (bishop.square().x() > 5)
{
result += table[index(9 - bishop.square().x(), bishop.square().y() - 1,
9 - silver.square().x(), silver.square().y() - 1,
9 - knight.square().x(), knight.square().y() - 1)];
}
else
{
result += table[index(bishop.square().x() - 1, bishop.square().y() - 1,
silver.square().x() - 1, silver.square().y() - 1,
knight.square().x() - 1, knight.square().y() - 1)];
}
}
else
{
if (bishop.square().x() >= 5)
{
result -= table[index(9 - bishop.square().x(), 9 - bishop.square().y(),
9 - silver.square().x(), 9 - silver.square().y(),
9 - knight.square().x(), 9 - knight.square().y())];
}
else
{
result -= table[index(bishop.square().x() - 1, 9 - bishop.square().y(),
silver.square().x() - 1, 9 - silver.square().y(),
knight.square().x() - 1, 9 - knight.square().y())];
}
}
}
}
}
return result;
}
␌
osl::CArray<MultiInt, osl::eval::ml::AttackMajorsInBase::ONE_DIM>
osl::eval::ml::AttackMajorsInBase::table;
void osl::eval::ml::
AttackMajorsInBase::setUp(const Weights &weights)
{
for (size_t i = 0; i < ONE_DIM; ++i) {
for (int s=0; s<NStages; ++s)
table[i][s] = weights.value(i + ONE_DIM*s);
if (i > 0)
table[i] += table[0];
}
}
template <osl::Player P>
void osl::eval::ml::
AttackMajorsInBase::addOne(const NumEffectState &state, Piece rook, MultiInt& result)
{
Square sq = rook.square();
if (state.hasEffectAt(alt(P), sq)
|| sq.squareForBlack(P).y() < 8)
return;
typedef std::pair<Offset,Square> pair_t;
const CArray<pair_t, 7> bishop_attack =
{{
pair_t(Offset::make<P,U>(), sq.neighbor<P, UL>()),
pair_t(Offset::make<P,U>(), sq.neighbor<P, UR>()),
pair_t(Offset::make<P,L>(), sq.neighbor<P, UL>()),
pair_t(Offset::make<P,R>(), sq.neighbor<P, UR>()),
pair_t(Offset::make<P,D>(), sq.neighbor<P, UL>()),
pair_t(Offset::make<P,D>(), sq.neighbor<P, UR>()),
pair_t(Offset::make<P,U>(), sq.neighbor<P, U>()),
}};
const bool has_gold = state.hasPieceOnStand(alt(P), GOLD);
const bool rook_support = state.hasEffectAt(P, sq);
for (pair_t pair: bishop_attack) {
const Square attack_square = pair.second;
if (! state[attack_square].isEmpty()
|| state.countEffect(P, attack_square) > 1)
continue;
const Square bishop_square = attack_square + pair.first;
Piece p = state[bishop_square];
if (! p.isPlayerPtype(P,BISHOP)
|| state.hasEffectAt(alt(P), bishop_square))
continue;
int a = state.countEffect(alt(P), attack_square) + has_gold;
if (a <= state.countEffect(P, attack_square))
continue;
const int i = index(state.findCheapAttack(P, attack_square).ptype(),
state.findCheapAttack(alt(P), attack_square).ptype(),
has_gold, rook_support,
state.hasEffectNotBy(P, rook, bishop_square));
if (P == BLACK)
result += table[i];
else
result -= table[i];
}
}
osl::MultiInt osl::eval::ml::
AttackMajorsInBase::eval(const NumEffectState &state)
{
MultiInt result;
for (int i=0; i<state.nthLimit<ROOK>(); ++i) {
const Piece rook = state.nth<ROOK>(i);
if (! rook.isOnBoard() || rook.isPromoted())
continue;
Player P = rook.owner();
if (P == BLACK)
addOne<BLACK>(state, rook, result);
else
addOne<WHITE>(state, rook, result);
}
return result;
}
␌
namespace osl
{
namespace eval
{
namespace ml
{
template class MajorY<true, ROOK>;
template class MajorY<false, ROOK>;
template class MajorY<true, BISHOP>;
template class MajorY<false, BISHOP>;
template class RookPawn<true>;
template class RookPawn<false>;
template class MajorGoldSilverAttacked<false>;
template MultiInt KingRookBishop::evalOne<BLACK>(const NumEffectState &state);
template MultiInt KingRookBishop::evalOne<WHITE>(const NumEffectState &state);
}
}
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::CArray
Definition container.h:20
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::NumEffectState::effectSetAt
const NumBitmapEffect effectSetAt(Square sq) const
Definition numEffectState.h:258
osl::NumEffectState::effectedMask
const PieceMask effectedMask(Player pl) const
pl からの利きが(1つ以上)ある駒一覧
Definition numEffectState.h:130
osl::NumEffectState::hasEffectNotBy
bool hasEffectNotBy(Player player, Piece piece, Square target) const
対象とするマスにあるプレイヤーの(ただしある駒以外)利きがあるかどうか.
Definition numEffectState.h:409
osl::NumEffectState::countEffect
int countEffect(Player player, Square target) const
利きの数を数える.
Definition numEffectState.h:266
osl::NumEffectState::hasEffectAt
bool hasEffectAt(Square target) const
対象とするマスにあるプレイヤーの利きがあるかどうか.
Definition numEffectState.h:324
osl::NumEffectState::hasLongEffectAt
bool hasLongEffectAt(Player P, Square to) const
あるマスにPTYPEの長い利きがあるかどうか.
Definition numEffectState.h:346
osl::NumEffectState::findCheapAttack
const Piece findCheapAttack(Player P, Square square) const
Definition numEffectState.h:560
osl::NumEffectState::mobilityOf
Square mobilityOf(Direction d, int num) const
Definition numEffectState.h:175
osl::NumEffectState::hasEffectIf
bool hasEffectIf(PtypeO ptypeo, Square attacker, Square target) const
attackerにptypeoの駒がいると仮定した場合にtargetに利きがあるかどうか を stateをupdateしないで確かめる.
Definition numEffectState.h:465
osl::NumEffectState::piecesOnBoard
const PieceMask & piecesOnBoard(Player p) const
Definition numEffectState.h:63
osl::NumEffectState::hasEffectByPtype
bool hasEffectByPtype(Player attack, Square target) const
target に ptype の利きがあるか?
Definition numEffectState.h:355
osl::Offset::make
static Offset make()
Definition directionTraits.h:265
osl::PieceMask
駒番号のビットセット.
Definition pieceMask.h:21
osl::PieceMask::any
bool any() const
Definition pieceMask.h:57
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::owner
Player owner() const
Definition basic_type.h:963
osl::Piece::isPlayerPtype
bool isPlayerPtype(Player pl, Ptype ptype) const
あるpieceがPlayer pの持ち物でPtype ptypeであるかどうかをチェックする． TはEMPTY, EDGEではない．
Definition basic_type.h:937
osl::Piece::canMoveOn
bool canMoveOn() const
Player Pの駒が，thisの上に移動できるか?
Definition basic_type.h:980
osl::Piece::number
int number() const
Definition basic_type.h:828
osl::Piece::isOnBoardNotPromoted
bool isOnBoardNotPromoted() const
promoteしていないOnBoardの駒であることのチェック Lance位しか使い道がない?
Definition basic_type.h:904
osl::Piece::isOnBoard
bool isOnBoard() const
Definition basic_type.h:985
osl::SimpleState::hasPieceOnStand
bool hasPieceOnStand(Player player, Ptype ptype) const
Definition simpleState.h:191
osl::SimpleState::nth
const Piece nth(int n) const
unpromote(PTYPE)のn番目の駒を帰す.
Definition simpleState.h:114
osl::SimpleState::turn
Player turn() const
Definition simpleState.h:220
osl::SimpleState::pieceOf
const Piece pieceOf(int num) const
Definition simpleState.h:76
osl::SimpleState::nthLimit
static int nthLimit()
Definition simpleState.h:105
osl::SimpleState::kingSquare
Square kingSquare() const
Definition simpleState.h:94
osl::SimpleState::isPawnMaskSet
bool isPawnMaskSet(Player player, int x) const
Definition simpleState.h:146
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition simpleState.h:167
osl::Square
Definition basic_type.h:532
osl::Square::rotate180EdgeOK
const Square rotate180EdgeOK() const
Definition basic_type.h:617
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
osl::Square::neighbor
const Square neighbor() const
Definition basic_type.h:746
osl::Square::canPromote
bool canPromote() const
Definition basic_type.h:659
osl::Square::rotate180
const Square rotate180() const
Definition basic_type.h:613
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::x
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
osl::container::PieceMask64::takeOneBit
int takeOneBit()
Definition pieceMask64.h:82
osl::effect::NumBitmapEffect
現在の定義 (2005/3/4以降)
Definition numBitmapEffect.h:29
osl::eval::ml::AllMajor::weight
static MultiInt weight
Definition majorPiece.h:131
osl::eval::ml::AllMajor::setUp
static void setUp(const Weights &weights, int stage)
Definition majorPiece.cc:127
osl::eval::ml::AttackMajorsInBase::index
static int index(Ptype support, Ptype attack, bool has_gold, bool rook_support, bool bishop_support)
Definition majorPiece.h:700
osl::eval::ml::AttackMajorsInBase::addOne
static void addOne(const NumEffectState &state, Piece rook, MultiInt &)
Definition majorPiece.cc:1439
osl::eval::ml::AttackMajorsInBase::table
static CArray< MultiInt, ONE_DIM > table
Definition majorPiece.h:698
osl::eval::ml::AttackMajorsInBase::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:1427
osl::eval::ml::AttackMajorsInBase::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:692
osl::eval::ml::AttackMajorsInBase::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:1483
osl::eval::ml::BishopBishopPiece::index
static int index(Ptype ptype, bool self_with_support, bool opp_with_support)
Definition majorPiece.h:539
osl::eval::ml::BishopBishopPiece::table
static CArray< MultiInt, 64 > table
Definition majorPiece.h:545
osl::eval::ml::BishopBishopPiece::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:923
osl::eval::ml::BishopBishopPiece::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:933
osl::eval::ml::BishopBishopPiece::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:535
osl::eval::ml::BishopEffectBase::defense_table
static CArray< MultiInt, 612 > defense_table
Definition majorPiece.h:394
osl::eval::ml::BishopEffectBase::defense_ur
static CArray< MultiInt, 23104 > defense_ur
Definition majorPiece.h:400
osl::eval::ml::BishopEffectBase::attack_ur
static CArray< MultiInt, 23104 > attack_ur
Definition majorPiece.h:396
osl::eval::ml::BishopEffectBase::defense_dr
static CArray< MultiInt, 23104 > defense_dr
Definition majorPiece.h:402
osl::eval::ml::BishopEffectBase::attack_table
static CArray< MultiInt, 612 > attack_table
Definition majorPiece.h:393
osl::eval::ml::BishopEffectBase::index0
static int index0(int x_diff, int y_diff, PtypeO ptypeO, bool ur, bool promoted)
Definition majorPiece.h:329
osl::eval::ml::BishopEffectBase::attack_dr
static CArray< MultiInt, 23104 > attack_dr
Definition majorPiece.h:398
osl::eval::ml::BishopEffectBase::index
static int index(int x_diff, int y_diff, bool ur, bool promoted)
Definition majorPiece.h:323
osl::eval::ml::BishopEffectBase::attack_nospace
static CArray< MultiInt, 722 > attack_nospace
Definition majorPiece.h:404
osl::eval::ml::BishopEffectBase::index1
static int index1(Square king, Square from, PtypeO ptypeO, bool isP)
黒の角(馬)からの利きのある駒のindex {attack,defense}_{ul,ur,dl,dr} へのアクセスに使う from - 駒の位置 king - 玉の位置 ptypeO - 駒の種類，...
Definition majorPiece.h:345
osl::eval::ml::BishopEffectBase::defense_nospace
static CArray< MultiInt, 722 > defense_nospace
Definition majorPiece.h:405
osl::eval::ml::BishopEffectBase::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:523
osl::eval::ml::BishopEffectBase::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:310
osl::eval::ml::BishopEffectBase::piece_table
static CArray< MultiInt, 32 > piece_table
Definition majorPiece.h:395
osl::eval::ml::BishopEffectBase::index2
static int index2(Square king, Square from, bool isP)
黒の角(馬)がある場所は空マスでないのでその分を補正するテーブル {attack,defense}_nospace へのアクセス king - 玉の位置 from - 角(馬)の位置 isP - 馬の場...
Definition majorPiece.h:374
osl::eval::ml::BishopEffectBase::defense_dl
static CArray< MultiInt, 23104 > defense_dl
Definition majorPiece.h:403
osl::eval::ml::BishopEffectBase::attack_ul
static CArray< MultiInt, 23104 > attack_ul
Definition majorPiece.h:397
osl::eval::ml::BishopEffectBase::defense_ul
static CArray< MultiInt, 23104 > defense_ul
Definition majorPiece.h:401
osl::eval::ml::BishopEffectBase::attack_dl
static CArray< MultiInt, 23104 > attack_dl
Definition majorPiece.h:399
osl::eval::ml::BishopEffectBase::evalOne
static MultiInt evalOne(const NumEffectState &state, Square bishop, Square myKing, Square opKing, Square ulp, Square urp, Square dlp, Square drp, bool isP)
Definition majorPiece.cc:480
osl::eval::ml::BishopEffectPieceKingRelative::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:570
osl::eval::ml::BishopEffectPieceKingRelative::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:422
osl::eval::ml::BishopEffectPiece::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:559
osl::eval::ml::BishopEffect::setUp
static void setUp(const Weights &weights, int stage)
Definition majorPiece.cc:550
osl::eval::ml::BishopHeadKingRelative::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:468
osl::eval::ml::BishopHeadKingRelative::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:674
osl::eval::ml::BishopHeadX::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:474
osl::eval::ml::BishopHeadX::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:697
osl::eval::ml::BishopHead::table
static CArray< MultiInt, 32 > table
Definition majorPiece.h:460
osl::eval::ml::BishopHead::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:707
osl::eval::ml::BishopHead::indexK
static int indexK(Player player, PtypeO ptypeO, int x_diff, int y_diff)
Definition majorPiece.h:435
osl::eval::ml::BishopHead::indexX
static int indexX(PtypeO ptypeO, int x)
Definition majorPiece.h:448
osl::eval::ml::BishopHead::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:664
osl::eval::ml::BishopHead::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:431
osl::eval::ml::BishopHead::king_table
static CArray< MultiInt, 4896 > king_table
Definition majorPiece.h:461
osl::eval::ml::BishopHead::x_table
static CArray< MultiInt, 160 > x_table
Definition majorPiece.h:462
osl::eval::ml::BishopSilverKnight::index
static size_t index(int bishop_x, int bishop_y, int silver_x, int silver_y, int knight_x, int knight_y)
Definition majorPiece.h:681
osl::eval::ml::BishopSilverKnight::table
static CArray< MultiInt, ONE_DIM > table
Definition majorPiece.h:680
osl::eval::ml::BishopSilverKnight::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:674
osl::eval::ml::BishopSilverKnight::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:1353
osl::eval::ml::BishopSilverKnight::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:1343
osl::eval::ml::BishopStandFile5::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:1177
osl::eval::ml::BishopStandFile5::table
static CArray< MultiInt, 32 > table
Definition majorPiece.h:630
osl::eval::ml::BishopStandFile5::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:626
osl::eval::ml::BishopStandFile5::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:1187
osl::eval::ml::KingRookBishop::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:790
osl::eval::ml::KingRookBishop::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:480
osl::eval::ml::KingRookBishop::table
static CArray< MultiInt, 374544 > table
Definition majorPiece.h:486
osl::eval::ml::KingRookBishop::index
static int index(const Square king, const Piece rook, const Piece bishop)
Definition majorPiece.h:488
osl::eval::ml::KingRookBishop::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:750
osl::eval::ml::KingRookBishop::evalOne
static MultiInt evalOne(const NumEffectState &state)
Definition majorPiece.cc:761
osl::eval::ml::MajorCheckWithCapture::index
static size_t index(Ptype ptype, bool is_rook, bool can_promote)
Definition majorPiece.h:646
osl::eval::ml::MajorCheckWithCapture::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:637
osl::eval::ml::MajorCheckWithCapture::table
static CArray< MultiInt, ONE_DIM > table
Definition majorPiece.h:643
osl::eval::ml::MajorCheckWithCapture::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:1209
osl::eval::ml::MajorCheckWithCapture::addOne
static MultiInt addOne(const NumEffectState &state)
osl::eval::ml::MajorCheckWithCapture::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:1249
osl::eval::ml::MajorGoldSilverAttacked
Definition majorPiece.h:136
osl::eval::ml::MajorGoldSilverAttacked::eval
static int eval(const NumEffectState &state)
Definition majorPiece.cc:180
osl::eval::ml::MajorGoldSilverAttacked::evalOne
static int evalOne(const NumEffectState &state)
Definition majorPiece.cc:157
osl::eval::ml::MajorGoldSilverAttacked::index
static int index(const NumEffectState &state, Piece piece)
Definition majorPiece.cc:148
osl::eval::ml::MajorGoldSilverAttacked::table
static CArray< int, 32 > table
Definition majorPiece.h:145
osl::eval::ml::MajorGoldSilverAttacked::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:138
osl::eval::ml::MajorY
Definition majorPiece.h:20
osl::eval::ml::MajorY::table
static CArray< int, 18 > table
Definition majorPiece.h:22
osl::eval::ml::MajorY::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:12
osl::eval::ml::NumPiecesBetweenBishopAndKingAll::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:823
osl::eval::ml::NumPiecesBetweenBishopAndKingAll::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:529
osl::eval::ml::NumPiecesBetweenBishopAndKingOpp::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:812
osl::eval::ml::NumPiecesBetweenBishopAndKingOpp::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:523
osl::eval::ml::NumPiecesBetweenBishopAndKingSelf::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:517
osl::eval::ml::NumPiecesBetweenBishopAndKingSelf::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:801
osl::eval::ml::NumPiecesBetweenBishopAndKing::opp_table
static CArray< MultiInt, 9 > opp_table
Definition majorPiece.h:511
osl::eval::ml::NumPiecesBetweenBishopAndKing::all_table
static CArray< MultiInt, 9 > all_table
Definition majorPiece.h:512
osl::eval::ml::NumPiecesBetweenBishopAndKing::self_table
static CArray< MultiInt, 9 > self_table
Definition majorPiece.h:510
osl::eval::ml::NumPiecesBetweenBishopAndKing::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:834
osl::eval::ml::NumPiecesBetweenBishopAndKing::countBetween
static void countBetween(const NumEffectState &state, Square king, Piece bishop, int &self_count, int &opp_count, int &total_count)
Definition majorPiece.cc:863
osl::eval::ml::RookEffectBase::attack_d
static CArray< MultiInt, 23104 > attack_d
Definition majorPiece.h:257
osl::eval::ml::RookEffectBase::evalOne
static MultiInt evalOne(const NumEffectState &state, Square rook, Square myKing, Square opKing, Square up, Square dp, Square rp, Square lp, bool isP)
Definition majorPiece.cc:209
osl::eval::ml::RookEffectBase::defense_d
static CArray< MultiInt, 23104 > defense_d
Definition majorPiece.h:261
osl::eval::ml::RookEffectBase::defense_u
static CArray< MultiInt, 23104 > defense_u
Definition majorPiece.h:260
osl::eval::ml::RookEffectBase::attack_table
static CArray< MultiInt, 612 > attack_table
Definition majorPiece.h:253
osl::eval::ml::RookEffectBase::index0
static int index0(int abs_x_diff, int y_diff, PtypeO ptypeO, bool horizontal, bool promoted)
黒の飛車(竜)から利きのある駒 (abs_x_diff, y_diff) - 駒を基準にした玉の相対位置 abs_x_diffは絶対値 ptypeO - 駒のptypeO,...
Definition majorPiece.h:190
osl::eval::ml::RookEffectBase::attack_u
static CArray< MultiInt, 23104 > attack_u
Definition majorPiece.h:256
osl::eval::ml::RookEffectBase::attack_l
static CArray< MultiInt, 23104 > attack_l
Definition majorPiece.h:258
osl::eval::ml::RookEffectBase::attack_r
static CArray< MultiInt, 23104 > attack_r
Definition majorPiece.h:259
osl::eval::ml::RookEffectBase::attack_nospace
static CArray< MultiInt, 722 > attack_nospace
Definition majorPiece.h:264
osl::eval::ml::RookEffectBase::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:159
osl::eval::ml::RookEffectBase::defense_nospace
static CArray< MultiInt, 722 > defense_nospace
Definition majorPiece.h:265
osl::eval::ml::RookEffectBase::defense_r
static CArray< MultiInt, 23104 > defense_r
Definition majorPiece.h:263
osl::eval::ml::RookEffectBase::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:254
osl::eval::ml::RookEffectBase::defense_table
static CArray< MultiInt, 612 > defense_table
Definition majorPiece.h:254
osl::eval::ml::RookEffectBase::index2
static int index2(Square king, Square from, bool isP)
黒の飛車(竜)がある場所は空マスでないのでその分を補正するテーブル {attack,defense}_nospace へのアクセス king - 玉の位置 from - 飛車(竜)の位置 isP - 竜...
Definition majorPiece.h:234
osl::eval::ml::RookEffectBase::index1
static int index1(Square king, Square from, PtypeO ptypeO, bool isP)
黒の飛車(竜)からの利きのある駒のindex {attack,defense}_{u,r,l,d} へのアクセスに使う from - 駒の位置 king - 玉の位置 ptypeO - 駒の種類，白から...
Definition majorPiece.h:205
osl::eval::ml::RookEffectBase::index
static int index(int abs_x_diff, int y_diff, bool horizontal, bool is_promoted)
(abs_x_diff, y_diff) - 玉を原点とした時の空マスの相対位置 horizontal - 飛車の横利きがある場合 is_promoted - 竜の場合
Definition majorPiece.h:177
osl::eval::ml::RookEffectBase::piece_table
static CArray< MultiInt, 32 > piece_table
Definition majorPiece.h:255
osl::eval::ml::RookEffectBase::defense_l
static CArray< MultiInt, 23104 > defense_l
Definition majorPiece.h:262
osl::eval::ml::RookEffectPieceKingRelative::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:282
osl::eval::ml::RookEffectPieceKingRelative::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:299
osl::eval::ml::RookEffectPiece::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:289
osl::eval::ml::RookEffect::setUp
static void setUp(const Weights &weights, int stage)
Definition majorPiece.cc:280
osl::eval::ml::RookPawnYX::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:112
osl::eval::ml::RookPawnYX::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:60
osl::eval::ml::RookPawnY::table
static CArray< MultiInt, 180 > table
Definition majorPiece.h:104
osl::eval::ml::RookPawnY::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:85
osl::eval::ml::RookPawnY::eval
static MultiInt eval(const NumEffectState &state, const CArray2d< int, 2, 9 > &pawns)
Definition majorPiece.cc:84
osl::eval::ml::RookPawnY::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:74
osl::eval::ml::RookPawnY::indexY
static int indexY(const Square king, const Piece rook, int pawn_y)
Definition majorPiece.h:96
osl::eval::ml::RookPawnY::y_attack_table
static CArray< MultiInt, 1620 > y_attack_table
Definition majorPiece.h:105
osl::eval::ml::RookPawnY::y_defense_table
static CArray< MultiInt, 1620 > y_defense_table
Definition majorPiece.h:106
osl::eval::ml::RookPawnY::index
static int index(const Piece rook, const int pawn_y)
Definition majorPiece.h:90
osl::eval::ml::RookPawn
Definition majorPiece.h:66
osl::eval::ml::RookPawn::eval
static int eval(const NumEffectState &state)
Definition majorPiece.cc:32
osl::eval::ml::RookPawn::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:26
osl::eval::ml::RookPawn::weight
static int weight
Definition majorPiece.h:72
osl::eval::ml::RookPromoteDefenseRookH::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:301
osl::eval::ml::RookPromoteDefenseRookH::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:387
osl::eval::ml::RookPromoteDefense::promote_defense_table
static CArray< MultiInt, 256 > promote_defense_table
Definition majorPiece.h:294
osl::eval::ml::RookPromoteDefense::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:290
osl::eval::ml::RookPromoteDefense::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:398
osl::eval::ml::RookPromoteDefense::promote_defense_rook_table
static CArray< MultiInt, 144 > promote_defense_rook_table
Definition majorPiece.h:295
osl::eval::ml::RookPromoteDefense::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:378
osl::eval::ml::RookRookPiece::table
static CArray< MultiInt, 128 > table
Definition majorPiece.h:620
osl::eval::ml::RookRookPiece::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:1104
osl::eval::ml::RookRookPiece::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:609
osl::eval::ml::RookRookPiece::index
static int index(Ptype ptype, bool self_with_support, bool opp_with_support, bool vertical)
Definition majorPiece.h:613
osl::eval::ml::RookRookPiece::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:1094
osl::eval::ml::RookRook::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:1002
osl::eval::ml::RookRook::index
static int index(Piece rook1, Piece rook2)
Definition majorPiece.h:556
osl::eval::ml::RookRook::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:1062
osl::eval::ml::RookRook::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:551
osl::eval::ml::RookRook::table
static CArray< MultiInt, 800 > table
Definition majorPiece.h:603
osl::eval::ml::RookSilverKnight::setUp
static void setUp(const Weights &weights)
Definition majorPiece.cc:1259
osl::eval::ml::RookSilverKnight::ONE_DIM
@ ONE_DIM
Definition majorPiece.h:656
osl::eval::ml::RookSilverKnight::table
static CArray< MultiInt, ONE_DIM > table
Definition majorPiece.h:662
osl::eval::ml::RookSilverKnight::eval
static MultiInt eval(const NumEffectState &state)
Definition majorPiece.cc:1269
osl::eval::ml::RookSilverKnight::index
static size_t index(int rook_x, int rook_y, int silver_x, int silver_y, int knight_x, int knight_y)
Definition majorPiece.h:663
majorPiece.h
osl::effect
Definition effectedNumTable.h:8
osl::eval::ml
Definition eval_pieceStand.cc:470
osl::eval
Definition eval_pieceStand.cc:468
osl
Definition additionalEffect.h:6
osl::PTYPEO_EMPTY
const PtypeO PTYPEO_EMPTY
Definition basic_type.h:303
osl::ROOK
@ ROOK
Definition basic_type.h:100
osl::BISHOP
@ BISHOP
Definition basic_type.h:99
osl::PTYPE_EDGE
@ PTYPE_EDGE
Definition basic_type.h:86
osl::PTYPE_EMPTY
@ PTYPE_EMPTY
Definition basic_type.h:85
osl::GOLD
@ GOLD
Definition basic_type.h:94
osl::CArray2d
CArray< CArray< T, Capacity2 >, Capacity1 > CArray2d
Definition container.h:95
osl::PTYPE_SIZE
const int PTYPE_SIZE
Definition basic_type.h:107
osl::getPtype
Ptype getPtype(PtypeO ptypeO)
Definition basic_type.h:217
osl::NStages
const int NStages
Definition midgame.h:11
osl::Board_Table
const BoardTable Board_Table
Definition tables.cc:95
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::MultiInt
QuadInt MultiInt
Definition midgame.h:13
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::PTYPEO_MAX
@ PTYPEO_MAX
Definition basic_type.h:201
osl::PTYPEO_MIN
@ PTYPEO_MIN
Definition basic_type.h:200
osl::alt
constexpr Player alt(Player player)
Definition basic_type.h:13
osl::newPtypeO
PtypeO newPtypeO(Player player, Ptype ptype)
Definition basic_type.h:211
osl::altIfPiece
PtypeO altIfPiece(PtypeO ptypeO)
Pieceの時にはowner を反転する
Definition basic_type.h:281
osl::inverse
constexpr Direction inverse(Direction d)
Definition basic_type.h:358
rookMobility.h
osl::DirectionPlayerTraits
Definition directionTraits.h:242
osl::PtypeTraits
Definition ptypeTraits.h:12
osl::eval::ml::Weights
Definition weights.h:18
osl::eval::ml::Weights::dimension
size_t dimension() const
Definition weights.h:29
osl::eval::ml::Weights::value
int value(size_t index) const
Definition weights.h:27
osl::mobility::RookMobility::countHorizontalAll
static int countHorizontalAll(const NumEffectState &state, int num)
Definition rookMobility.h:103