king8.cc
Go to the documentation of this file.
#include "osl/eval/king8.h"
#include <cstdlib>
using osl::MultiInt;
using osl::MultiIntPair;
template <bool Opening>
osl::CArray<int, 32> osl::eval::ml::King8EffectEmptySquare<Opening>::table;
template <bool Opening>
osl::CArray<int, 32> osl::eval::ml::King8EffectDefenseSquare<Opening>::table;
osl::CArray<int, 32> osl::eval::ml::King8Effect::empty_table;
osl::CArray<int, 32> osl::eval::ml::King8Effect::defense_table;
osl::CArray<int, 288> osl::eval::ml::King8Effect::empty_y_table;
osl::CArray<int, 288> osl::eval::ml::King8Effect::defense_y_table;
void osl::eval::ml::
King8Effect::setUp(const Weights &weights)
{
for (size_t i = 0; i < empty_table.size(); ++i)
{
empty_table[i] = weights.value(i);
}
for (size_t i = 0; i < defense_table.size(); ++i)
{
defense_table[i] = weights.value(i + empty_table.size());
}
for (size_t i = 0; i < empty_y_table.size(); ++i)
{
empty_y_table[i] = weights.value(i + empty_table.size() +
defense_table.size());
}
for (size_t i = 0; i < defense_y_table.size(); ++i)
{
defense_y_table[i] = weights.value(i + empty_table.size() +
defense_table.size() +
empty_y_table.size());
}
}
int osl::eval::ml::King8Effect::eval(
const NumEffectState &state)
{
int result = 0;
const Piece black_king = state.kingPiece<BLACK>();
const Piece white_king = state.kingPiece<WHITE>();
for (int i = SHORT8_DIRECTION_MIN; i <= SHORT8_DIRECTION_MAX; ++i)
{
const Direction dir = static_cast<Direction>(i);
{
EffectState empty, defense;
effectState(state, BLACK, dir, empty, defense);
if (empty != NOT_EMPTY)
{
result -= empty_table[index(dir, empty)];
result -= empty_y_table[indexY(black_king, dir, empty)];
}
if (defense != NOT_EMPTY)
{
result -= defense_table[index(dir, defense)];
result -= defense_y_table[indexY(black_king, dir, defense)];
}
}
{
EffectState empty, defense;
effectState(state, WHITE, dir, empty, defense);
if (empty != NOT_EMPTY)
{
result += empty_table[index(dir, empty)];
result += empty_y_table[indexY(white_king, dir, empty)];
}
if (defense != NOT_EMPTY)
{
result += defense_table[index(dir, defense)];
result += defense_y_table[indexY(white_king, dir, defense)];
}
}
}
return result;
}
int osl::eval::ml::
King8Effect::index(const Direction dir,
EffectState state)
{
return (dir * 4 + state);
}
int osl::eval::ml::
King8Effect::indexY(Piece king,
const Direction dir,
EffectState state)
{
const int y = ((king.owner() == BLACK) ?
king.square().y() : 10 - king.square().y());
return (dir * 4 + state) * 9 + y - 1;
}
void osl::eval::ml::
King8Effect::effectState(const NumEffectState &state,
const Player defenseP,
const Direction dir,
EffectState &empty,
EffectState &defense)
{
const Square target =
Board_Table.nextSquare(defenseP,
state.kingSquare(defenseP),
dir);
if (!state.pieceAt(target).isEmpty())
{
empty = defense = NOT_EMPTY;
return;
}
const int attack_count = state.countEffect(alt(defenseP), target);
const int defense_count = state.countEffect(defenseP, target);
if (attack_count == 0)
{
empty = NO_EFFECT;
defense = NO_EFFECT;
}
else if (defense_count == 1)
{
empty = MORE_EFFECT_KING_ONLY;
}
else if (attack_count >= defense_count)
{
empty = MORE_EFFECT;
}
else
{
empty = LESS_EFFECT;
}
if (defense_count == 1 && attack_count > defense_count)
{
defense = MORE_EFFECT_KING_ONLY;
}
else if (attack_count > defense_count)
{
defense = MORE_EFFECT;
}
else
{
defense = LESS_EFFECT;
}
}
␌
struct osl::eval::ml::King8EffectBase::
MakeEffectStateSimple
{
EffectState operator()(const NumEffectState &state,
const Player defense,
const Direction dir) const
{
const Square target =
Board_Table.nextSquare(defense,
state.kingSquare(defense),
dir);
if (!state.pieceAt(target).isEmpty())
return NOT_EMPTY;
const int attack_count = state.countEffect(alt(defense), target);
if (attack_count == 0)
return NO_EFFECT;
const int defense_count = state.countEffect(defense, target);
if (defense_count == 1)
return MORE_EFFECT_KING_ONLY;
else if (attack_count >= defense_count)
return MORE_EFFECT;
else
return LESS_EFFECT;
}
};
struct osl::eval::ml::King8EffectBase::
MakeEffectStateDefense
{
EffectState operator()(const NumEffectState &state,
const Player defense,
const Direction dir) const
{
const Square target =
Board_Table.nextSquare(defense,
state.kingSquare(defense),
dir);
if (!state.pieceAt(target).isOnBoardByOwner(defense))
return NOT_EMPTY;
const int attack_count = state.countEffect(alt(defense), target);
if (attack_count == 0)
return NO_EFFECT;
const int defense_count = state.countEffect(defense, target);
if (defense_count == 1 && attack_count > defense_count)
return MORE_EFFECT_KING_ONLY;
else if (attack_count > defense_count)
return MORE_EFFECT;
else
return LESS_EFFECT;
}
};
template <class MakeEffectState>
const osl::CArray<int,2>
#if (defined __GNUC__) && (! defined GPSONE) && (! defined GPSUSIONE)
__attribute__ ((used))
#endif
osl::eval::ml::
King8EffectBase::evalCommon(const NumEffectState &state, const table_t& table)
{
MakeEffectState f;
CArray<int,2> result = {{0, 0}};
for (int i = SHORT8_DIRECTION_MIN; i <= SHORT8_DIRECTION_MAX; ++i)
{
const Direction dir = static_cast<Direction>(i);
const EffectState black_effect_state = f(state, BLACK, dir);
if (black_effect_state != NOT_EMPTY)
{
result[0] -= table[index(dir, black_effect_state)];
}
const EffectState white_effect_state = f(state, WHITE, dir);
if (white_effect_state != NOT_EMPTY)
{
result[1] += table[index(dir, white_effect_state)];
}
}
return result;
}
template <class MakeEffectState>
const osl::CArray<int,2>
#if (defined __GNUC__) && (! defined GPSONE) && (! defined GPSUSIONE)
__attribute__ ((used))
#endif
osl::eval::ml::
King8EffectBase::evalWithUpdateCommon(const NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value, const table_t& table)
{
CArray<int,2> result = last_value;
MakeEffectState f;
BoardMask mask = new_state.changedEffects();
mask.set(last_move.to()); mask.set(last_move.from());
for (int z=0; z<2; ++z)
{
const Player pl = indexToPlayer(z);
const Square king = new_state.kingSquare(pl);
bool update = mask.anyInRange(Board_Mask_Table3x3.mask(king));
if (! update)
continue;
result[z] = 0;
for (int i = SHORT8_DIRECTION_MIN; i <= SHORT8_DIRECTION_MAX; ++i)
{
const Direction dir = static_cast<Direction>(i);
const EffectState effect_state = f(new_state, pl, dir);
if (effect_state != NOT_EMPTY)
{
result[z] -= table[index(dir, effect_state)];
}
}
if (z == 1)
result[1] = -result[1];
}
return result;
}
template <class MakeEffectState>
inline
std::pair<osl::CArray<int,2>, osl::CArray<int,2> > osl::eval::ml::
King8EffectBase::evalWithUpdateCommon(const NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value_o, const CArray<int,2>& last_value_e,
const table_t& table_o, const table_t& table_e)
{
CArray<int,2> result_o = last_value_o, result_e = last_value_e;
MakeEffectState f;
BoardMask mask = new_state.changedEffects();
mask.set(last_move.to()); mask.set(last_move.from());
for (int z=0; z<2; ++z)
{
const Player pl = indexToPlayer(z);
const Square king = new_state.kingSquare(pl);
bool update = mask.anyInRange(Board_Mask_Table3x3.mask(king));
if (! update)
continue;
result_o[z] = result_e[z] = 0;
for (int i = SHORT8_DIRECTION_MIN; i <= SHORT8_DIRECTION_MAX; ++i)
{
const Direction dir = static_cast<Direction>(i);
const EffectState effect_state = f(new_state, pl, dir);
if (effect_state != NOT_EMPTY)
{
result_o[z] -= table_o[index(dir, effect_state)];
result_e[z] -= table_e[index(dir, effect_state)];
}
}
if (z == 1)
{
result_o[1] = -result_o[1];
result_e[1] = -result_e[1];
}
}
return std::make_pair(result_o, result_e);
}
template <bool Opening>
void osl::eval::ml::
King8EffectEmptySquare<Opening>::setUp(const Weights &weights)
{
table.fill(0);
for (size_t i = 0; i < weights.dimension(); ++i)
{
table[i] = weights.value(i);
}
}
template <bool Opening>
const osl::CArray<int,2> osl::eval::ml::
King8EffectEmptySquare<Opening>::eval(const NumEffectState &state)
{
return evalCommon<MakeEffectStateSimple>(state, table);
}
template <bool Opening>
const osl::CArray<int,2> osl::eval::ml::
King8EffectEmptySquare<Opening>::evalWithUpdate(const NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value)
{
return evalWithUpdateCommon<MakeEffectStateSimple>
(new_state, last_move, last_value, table);
}
std::pair<osl::CArray<int,2>, osl::CArray<int,2> >
osl::eval::ml::King8EffectEmptySquareBoth::
evalWithUpdate(const NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value_opening,
const CArray<int,2>& last_value_ending)
{
return evalWithUpdateCommon<MakeEffectStateSimple>
(new_state, last_move, last_value_opening, last_value_ending,
King8EffectEmptySquare<true>::table, King8EffectEmptySquare<false>::table);
}
template <bool Opening>
void osl::eval::ml::
King8EffectDefenseSquare<Opening>::setUp(const Weights &weights)
{
table.fill(0);
for (size_t i = 0; i < weights.dimension(); ++i)
{
table[i] = weights.value(i);
}
}
template <bool Opening>
const osl::CArray<int,2> osl::eval::ml::
King8EffectDefenseSquare<Opening>::eval(const NumEffectState &state)
{
return evalCommon<MakeEffectStateDefense>(state, table);
}
template <bool Opening>
const osl::CArray<int,2> osl::eval::ml::
King8EffectDefenseSquare<Opening>::evalWithUpdate(const NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value)
{
return evalWithUpdateCommon<MakeEffectStateDefense>
(new_state, last_move, last_value, table);
}
std::pair<osl::CArray<int,2>, osl::CArray<int,2> >
osl::eval::ml::King8EffectDefenseSquareBoth::
evalWithUpdate(const NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value_opening,
const CArray<int,2>& last_value_ending)
{
return evalWithUpdateCommon<MakeEffectStateDefense>
(new_state, last_move, last_value_opening, last_value_ending,
King8EffectDefenseSquare<true>::table, King8EffectDefenseSquare<false>::table);
}
␌
osl::CArray<int, osl::eval::ml::King8EffectAll::ONE_DIM>
osl::eval::ml::King8EffectAll::base_table;
osl::CArray<int, osl::eval::ml::King8EffectAll::ONE_DIM>
osl::eval::ml::King8EffectAll::u_table;
osl::CArray<int, osl::eval::ml::King8EffectAll::ONE_DIM>
osl::eval::ml::King8EffectAll::d_table;
osl::CArray<int, osl::eval::ml::King8EffectAll::ONE_DIM>
osl::eval::ml::King8EffectAll::l_table;
osl::CArray<int, osl::eval::ml::King8EffectAll::ONE_DIM>
osl::eval::ml::King8EffectAll::r_table;
osl::CArray<int, osl::eval::ml::King8EffectAll::ONE_DIM>
osl::eval::ml::King8EffectAll::base_defense_piece_table;
osl::CArray<int, osl::eval::ml::King8EffectAll::ONE_DIM>
osl::eval::ml::King8EffectAll::u_defense_piece_table;
osl::CArray<int, osl::eval::ml::King8EffectAll::ONE_DIM>
osl::eval::ml::King8EffectAll::d_defense_piece_table;
osl::CArray<int, osl::eval::ml::King8EffectAll::ONE_DIM>
osl::eval::ml::King8EffectAll::l_defense_piece_table;
osl::CArray<int, osl::eval::ml::King8EffectAll::ONE_DIM>
osl::eval::ml::King8EffectAll::r_defense_piece_table;
void osl::eval::ml::
King8EffectAll::setUp(const Weights &weights)
{
base_table.fill(0);
u_table.fill(0);
d_table.fill(0);
l_table.fill(0);
r_table.fill(0);
base_defense_piece_table.fill(0);
u_defense_piece_table.fill(0);
d_defense_piece_table.fill(0);
l_defense_piece_table.fill(0);
r_defense_piece_table.fill(0);
for (size_t i = 0; i < ONE_DIM; ++i)
{
base_table[i] = weights.value(i);
u_table[i] = weights.value(i+ONE_DIM);
d_table[i] = weights.value(i+ONE_DIM*2);
l_table[i] = weights.value(i+ONE_DIM*3);
r_table[i] = weights.value(i+ONE_DIM*4);
base_defense_piece_table[i] = weights.value(i+ONE_DIM*5);
u_defense_piece_table[i] = weights.value(i+ONE_DIM*6);
d_defense_piece_table[i] = weights.value(i+ONE_DIM*7);
l_defense_piece_table[i] = weights.value(i+ONE_DIM*8);
r_defense_piece_table[i] = weights.value(i+ONE_DIM*9);
}
}
void
osl::eval::ml::King8EffectAll::effectState(
const NumEffectState &state,
const Player defense,
const Direction dir,
EffectState &empty, EffectState &defense_effect)
{
empty = NOT_EMPTY;
defense_effect = NOT_EMPTY;
const Square target =
Board_Table.nextSquare(defense,
state.kingSquare(defense),
dir);
const Piece piece = state.pieceAt(target);
if (!target.isOnBoard() ||
piece.isOnBoardByOwner(alt(defense)))
return;
const int attack_count = state.countEffect(alt(defense), target);
const int defense_count = state.countEffect(defense, target);
if (piece.isEmpty())
{
if (attack_count == 0)
empty = NO_EFFECT;
else if (defense_count == 1)
empty = MORE_EFFECT_KING_ONLY;
else if (attack_count >= defense_count)
empty = MORE_EFFECT;
else
empty = LESS_EFFECT;
}
else
{
if (attack_count == 0)
defense_effect = NO_EFFECT;
else if (defense_count == 1 && attack_count > defense_count)
defense_effect = MORE_EFFECT_KING_ONLY;
else if (attack_count > defense_count)
defense_effect = MORE_EFFECT;
else
defense_effect = LESS_EFFECT;
}
}
int osl::eval::ml::
King8EffectAll::index(const Direction dir, EffectState state)
{
return dir * 4 + state;
}
int osl::eval::ml::
King8EffectAll::eval(const NumEffectState &state,
PieceMask /*black_mask*/, PieceMask /*white_mask*/)
{
int result = 0;
osl::checkmate::King8Info black_king(state.Iking8Info(BLACK));
const int black_liberty = black_king.liberty();
const bool black_u_blocked =
(black_liberty & ((DirectionTraits<UL>::mask |
DirectionTraits<U>::mask |
DirectionTraits<UR>::mask))) == 0;
const bool black_d_blocked =
(black_liberty & ((DirectionTraits<DL>::mask |
DirectionTraits<D>::mask |
DirectionTraits<DR>::mask))) == 0;
const bool black_l_blocked =
(black_liberty & ((DirectionTraits<UL>::mask |
DirectionTraits<L>::mask |
DirectionTraits<DL>::mask))) == 0;
const bool black_r_blocked =
(black_liberty & ((DirectionTraits<UR>::mask |
DirectionTraits<R>::mask |
DirectionTraits<DR>::mask))) == 0;
osl::checkmate::King8Info white_king(state.Iking8Info(WHITE));
const int white_liberty = white_king.liberty();
const bool white_u_blocked =
(white_liberty & ((DirectionTraits<UL>::mask |
DirectionTraits<U>::mask |
DirectionTraits<UR>::mask))) == 0;
const bool white_d_blocked =
(white_liberty & ((DirectionTraits<DL>::mask |
DirectionTraits<D>::mask |
DirectionTraits<DR>::mask))) == 0;
const bool white_l_blocked =
(white_liberty & ((DirectionTraits<UL>::mask |
DirectionTraits<L>::mask |
DirectionTraits<DL>::mask))) == 0;
const bool white_r_blocked =
(white_liberty & ((DirectionTraits<UR>::mask |
DirectionTraits<R>::mask |
DirectionTraits<DR>::mask))) == 0;
for (int i = SHORT8_DIRECTION_MIN; i <= SHORT8_DIRECTION_MAX; ++i)
{
const Direction dir = static_cast<Direction>(i);
EffectState black_empty_effect_state,
black_defense_effect_state;
effectState(state, BLACK, dir,
black_empty_effect_state, black_defense_effect_state);
if (black_empty_effect_state != NOT_EMPTY)
{
const int idx = index(dir, black_empty_effect_state);
result -= base_table[idx];
if (black_u_blocked)
result -= u_table[idx];
if (black_d_blocked)
result -= d_table[idx];
if (black_l_blocked)
result -= l_table[idx];
if (black_r_blocked)
result -= r_table[idx];
}
if (black_defense_effect_state != NOT_EMPTY)
{
const int idx = index(dir, black_defense_effect_state);
result -= base_defense_piece_table[idx];
if (black_u_blocked)
result -= u_defense_piece_table[idx];
if (black_d_blocked)
result -= d_defense_piece_table[idx];
if (black_l_blocked)
result -= l_defense_piece_table[idx];
if (black_r_blocked)
result -= r_defense_piece_table[idx];
}
EffectState white_empty_effect_state,
white_defense_effect_state;
effectState(state, WHITE, dir,
white_empty_effect_state, white_defense_effect_state);
if (white_empty_effect_state != NOT_EMPTY)
{
const int idx = index(dir, white_empty_effect_state);
result += base_table[idx];
if (white_u_blocked)
result += u_table[idx];
if (white_d_blocked)
result += d_table[idx];
if (white_l_blocked)
result += l_table[idx];
if (white_r_blocked)
result += r_table[idx];
}
if (white_defense_effect_state != NOT_EMPTY)
{
const int idx = index(dir, white_defense_effect_state);
result += base_defense_piece_table[idx];
if (white_u_blocked)
result += u_defense_piece_table[idx];
if (white_d_blocked)
result += d_defense_piece_table[idx];
if (white_l_blocked)
result += l_defense_piece_table[idx];
if (white_r_blocked)
result += r_defense_piece_table[idx];
}
}
return result;
}
␌
osl::CArray<MultiInt, osl::eval::ml::KingXBothBlocked::ONE_DIM>
osl::eval::ml::KingXBothBlocked::table;
osl::CArray<MultiInt, osl::eval::ml::KingXBothBlockedY::ONE_DIM>
osl::eval::ml::KingXBothBlockedY::table;
void osl::eval::ml::
KingXBothBlocked::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);
}
}
void osl::eval::ml::
KingXBothBlockedY::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);
}
}
template <int Sign>
inline
void osl::eval::ml::
KingXBothBlocked::adjust(int index, int index_y, MultiInt &out)
{
if(Sign>0)
out += KingXBothBlocked::table[index] +KingXBothBlockedY::table[index_y];
else
out -= KingXBothBlocked::table[index] +KingXBothBlockedY::table[index_y];
}
MultiIntPair osl::eval::ml::
KingXBothBlocked::eval(const NumEffectState &state)
{
MultiIntPair result;
King8Info black(state.Iking8Info(BLACK));
if ((black.liberty() & (DirectionTraits<UL>::mask |
DirectionTraits<L>::mask |
DirectionTraits<DL>::mask |
DirectionTraits<UR>::mask |
DirectionTraits<R>::mask |
DirectionTraits<DR>::mask)) == 0)
{
const Square black_king = state.kingSquare<BLACK>();
adjust<1>(index(black_king),
indexY<BLACK>(black_king),
result[BLACK]);
}
King8Info white(state.Iking8Info(WHITE));
if ((white.liberty() & (DirectionTraits<UL>::mask |
DirectionTraits<L>::mask |
DirectionTraits<DL>::mask |
DirectionTraits<UR>::mask |
DirectionTraits<R>::mask |
DirectionTraits<DR>::mask)) == 0)
{
const Square white_king = state.kingSquare<WHITE>();
adjust<-1>(index(white_king),
indexY<WHITE>(white_king),
result[WHITE]);
}
return result;
}
template <osl::Player P>
int osl::eval::ml::KingXBlockedBase::index(
Square king, int diff)
{
const int king_x = king.x();
if (P == BLACK)
{
const int target_x = (king_x > 5) ? 10 - king_x : king_x;
int x_diff = diff;
if (king_x >= 6)
x_diff = -x_diff;
return target_x - 1 + ((x_diff == 1) ? 0 : 5);
}
else
{
const int target_x = (king_x > 5) ? 10 - king_x : king_x;
int x_diff = diff;
if (king_x >= 5)
x_diff = -x_diff;
return target_x - 1 + ((x_diff == 1) ? 0 : 5);
}
}
template <osl::Player P>
bool osl::eval::ml::KingXBlockedBase::isBlocked(
const NumEffectState &state,
int diff)
{
#if 1
const King8Info info(state.Iking8Info(P));
if ((diff == 1) ^ (P == BLACK))
return (info.liberty() & (DirectionTraits<UR>::mask
| DirectionTraits<R>::mask
| DirectionTraits<DR>::mask)) == 0;
assert((diff == 1 && P == BLACK) || (diff == -1 && P == WHITE));
return (info.liberty() & (DirectionTraits<UL>::mask
| DirectionTraits<L>::mask
| DirectionTraits<DL>::mask)) == 0;
#else
const Square pos = state.kingSquare<P>();
const int target_x = pos.x() + diff;
for (int y = pos.y() - 1; y <= pos.y() + 1; ++y)
{
Square target(target_x, y);
Piece p(state.pieceAt(target));
if ((!p.isEdge()) && ! p.isOnBoardByOwner<P>() &&
!state.hasEffectAt<alt(P)>(target))
{
return false;
}
}
return true;
#endif
}
const MultiIntPair osl::eval::ml::
KingXBlockedBase::eval(const NumEffectState &state, const table_t& table)
{
MultiIntPair val;
const Square black_king = state.kingSquare<BLACK>();
const Square white_king = state.kingSquare<WHITE>();
const int b = playerToIndex(BLACK), w = playerToIndex(WHITE);
if (isBlocked<BLACK>(state, 1))
val[b] += table[index<BLACK>(black_king, 1)];
if (isBlocked<BLACK>(state, -1))
val[b] += table[index<BLACK>(black_king, -1)];
if (isBlocked<WHITE>(state, 1))
val[w] -= table[index<WHITE>(white_king, 1)];
if (isBlocked<WHITE>(state, -1))
val[w] -= table[index<WHITE>(white_king, -1)];
return val;
}
const MultiIntPair osl::eval::ml::
KingXBlockedYBase::eval(const NumEffectState &state,
const table_t& table)
{
MultiIntPair val;
const Square black_king = state.kingSquare<BLACK>();
const Square white_king = state.kingSquare<WHITE>();
const int b = playerToIndex(BLACK), w = playerToIndex(WHITE);
const bool black_r_blocked = KingXBlockedBase::isBlocked<BLACK>(state, 1);
const bool black_l_blocked = KingXBlockedBase::isBlocked<BLACK>(state, -1);
if (black_r_blocked)
val[b] += table[index<BLACK>(black_king, 1)];
if (black_l_blocked)
val[b] += table[index<BLACK>(black_king, -1)];
const bool white_r_blocked = KingXBlockedBase::isBlocked<WHITE>(state, 1);
const bool white_l_blocked = KingXBlockedBase::isBlocked<WHITE>(state, -1);
if (white_r_blocked)
val[w] -= table[index<WHITE>(white_king, 1)];
if (white_l_blocked)
val[w] -= table[index<WHITE>(white_king, -1)];
return val;
}
#if 0
inline
std::pair<osl::CArray<int,2>,osl::CArray<int,2> >
osl::eval::ml::
KingXBlockedBase::evalWithUpdate(const NumEffectState &new_state, Move last_move,
const CArray<int,2>& last_value_o, const CArray<int,2>& last_value_e,
const table_t& table_o, const table_t& table_e)
{
CArray<int,2> val_o = last_value_o;
CArray<int,2> val_e = last_value_e;
const Square black_king = new_state.kingSquare<BLACK>();
const Square white_king = new_state.kingSquare<WHITE>();
BoardMask mask = new_state.changedEffects();
mask.set(last_move.from()); mask.set(last_move.to());
if (mask.anyInRange(Board_Mask_Table3x3.mask(black_king)))
{
const int b = playerToIndex(BLACK);
val_o[b] = val_e[b]= 0;
if (isBlocked<BLACK>(new_state, 1)) {
val_o[b] += table_o[index<BLACK>(black_king, 1)];
val_e[b] += table_e[index<BLACK>(black_king, 1)];
}
if (isBlocked<BLACK>(new_state, -1)) {
val_o[b] += table_o[index<BLACK>(black_king, -1)];
val_e[b] += table_e[index<BLACK>(black_king, -1)];
}
}
if (mask.anyInRange(Board_Mask_Table3x3.mask(white_king)))
{
const int w = playerToIndex(WHITE);
val_o[w] = val_e[w]= 0;
if (isBlocked<WHITE>(new_state, 1)) {
val_o[w] -= table_o[index<WHITE>(white_king, 1)];
val_e[w] -= table_e[index<WHITE>(white_king, 1)];
}
if (isBlocked<WHITE>(new_state, -1)) {
val_o[w] -= table_o[index<WHITE>(white_king, -1)];
val_e[w] -= table_e[index<WHITE>(white_king, -1)];
}
}
return std::make_pair(val_o, val_e);
}
#endif
template <int Sign>
inline
void osl::eval::ml::
KingXBlockedYBase::adjust(int index, int index_y, MultiInt &out)
{
if(Sign>0)
out += KingXBlocked::table[index]+ KingXBlockedY::table[index_y];
else
out -= KingXBlocked::table[index]+ KingXBlockedY::table[index_y];
}
inline
void
osl::eval::ml::
KingXBlockedYBase::evalWithUpdateBang(const NumEffectState &new_state,
Move last_move,
MultiIntPair& values)
{
const Square black_king = new_state.kingSquare<BLACK>();
const Square white_king = new_state.kingSquare<WHITE>();
BoardMask mask = new_state.changedEffects();
mask.set(last_move.from()); mask.set(last_move.to());
if (mask.anyInRange(Board_Mask_Table3x3.mask(black_king)))
{
values[BLACK].clear();
const bool black_r_blocked = KingXBlockedBase::isBlocked<BLACK>(new_state, 1);
const bool black_l_blocked = KingXBlockedBase::isBlocked<BLACK>(new_state, -1);
if (black_r_blocked) {
adjust<1>(KingXBlockedBase::index<BLACK>(black_king, 1),
index<BLACK>(black_king, 1),
values[BLACK]);
}
if (black_l_blocked) {
adjust<1>(KingXBlockedBase::index<BLACK>(black_king, -1),
index<BLACK>(black_king, -1),
values[BLACK]);
}
if (black_r_blocked && black_l_blocked)
{
KingXBothBlocked::adjust<1>(KingXBothBlocked::index(black_king),
KingXBothBlocked::indexY<BLACK>(black_king),
values[BLACK]);
}
}
if (mask.anyInRange(Board_Mask_Table3x3.mask(white_king)))
{
values[WHITE].clear();
const bool white_r_blocked = KingXBlockedBase::isBlocked<WHITE>(new_state, 1);
const bool white_l_blocked = KingXBlockedBase::isBlocked<WHITE>(new_state, -1);
if (white_r_blocked) {
adjust<-1>(KingXBlockedBase::index<WHITE>(white_king, 1),
index<WHITE>(white_king, 1),
values[WHITE]);
}
if (white_l_blocked) {
adjust<-1>(KingXBlockedBase::index<WHITE>(white_king, -1),
index<WHITE>(white_king, -1),
values[WHITE]);
}
if (white_r_blocked && white_l_blocked)
{
KingXBothBlocked::adjust<-1>(KingXBothBlocked::index(white_king),
KingXBothBlocked::indexY<WHITE>(white_king),
values[WHITE]);
}
}
}
template <osl::Player P> inline
int osl::eval::ml::KingXBlockedYBase::index(
Square king, int diff)
{
const int king_x = king.x();
if (P == BLACK)
{
const int king_y = king.y();
const int target_x = (king_x > 5) ? 10 - king_x : king_x;
int x_diff = diff;
if (king_x >= 6)
x_diff = -x_diff;
return (target_x - 1 + ((x_diff == 1) ? 0 : 5)) * 9 + king_y - 1;
}
else
{
const int king_y = 10 - king.y();
const int target_x = (king_x > 5) ? 10 - king_x : king_x;
int x_diff = diff;
if (king_x >= 5)
x_diff = -x_diff;
return (target_x - 1 + ((x_diff == 1) ? 0 : 5)) * 9 + king_y - 1;
}
}
osl::CArray<MultiInt, 10> osl::eval::ml::KingXBlocked::table;
osl::CArray<MultiInt, 90> osl::eval::ml::KingXBlockedY::table;
void osl::eval::ml::
KingXBlocked::setUp(const Weights &weights,int stage)
{
for (size_t i = 0; i < table.size(); ++i)
{
table[i][stage] = weights.value(i);
}
}
void
osl::eval::ml::
KingXBlockedBoth::evalWithUpdateBang(const NumEffectState &new_state, Move last_move,
MultiIntPair& last_values)
{
KingXBlockedYBase::evalWithUpdateBang
(new_state, last_move, last_values);
}
void osl::eval::ml::
KingXBlockedY::setUp(const Weights &weights,int stage)
{
for (size_t i = 0; i < table.size(); ++i)
{
table[i][stage] = weights.value(i);
}
}
␌
osl::CArray<MultiInt, 80> osl::eval::ml::KingXBlocked3::table;
osl::CArray<MultiInt, 720> osl::eval::ml::KingXBlocked3::y_table;
void osl::eval::ml::KingXBlocked3::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);
}
}
void osl::eval::ml::KingXBlocked3Y::setUp(const Weights &weights)
{
for (int i = 0; i < ONE_DIM; ++i)
{
for (int s=0; s<NStages; ++s)
KingXBlocked3::y_table[i][s] = weights.value(i + ONE_DIM*s);
}
for(int x=1;x<=5;x++)
for(int y=1;y<=9;y++)
for(int is_l=0;is_l<2;is_l++)
for(int u_blocked=0;u_blocked<2;u_blocked++)
for(int opp_u_blocked=0;opp_u_blocked<2;opp_u_blocked++)
for(int opp_blocked=0;opp_blocked<2;opp_blocked++){
int indexY=x - 1 + 5 * (y - 1 + 9 * ((is_l ? 1 : 0) + 2 * ((u_blocked ? 1 : 0) + 2 * ((opp_u_blocked ? 1 : 0) + 2 * (opp_blocked ? 1 : 0)))));
int index0=x - 1 + 5 * ((is_l ? 1 : 0) + 2 * ((u_blocked ? 1 : 0) + 2 * ((opp_u_blocked ? 1 : 0) + 2 * (opp_blocked ? 1 : 0))));
KingXBlocked3::y_table[indexY]+=KingXBlocked3::table[index0];
}
}
MultiInt osl::eval::ml::
KingXBlocked3::eval(const NumEffectState &state)
{
MultiInt result;
King8Info black(state.Iking8Info(BLACK));
if ((black.liberty() & (DirectionTraits<UL>::mask |
DirectionTraits<L>::mask |
DirectionTraits<DL>::mask)) == 0)
{
adjust<1>(
indexY<BLACK>(state.kingSquare<BLACK>(),
true,
(black.liberty() & DirectionTraits<U>::mask) == 0,
(black.liberty() & DirectionTraits<UR>::mask) == 0,
(black.liberty() & DirectionTraits<R>::mask) == 0),
result);
}
if ((black.liberty() & (DirectionTraits<UR>::mask |
DirectionTraits<R>::mask |
DirectionTraits<DR>::mask)) == 0)
{
adjust<1>(
indexY<BLACK>(state.kingSquare<BLACK>(),
false,
(black.liberty() & DirectionTraits<U>::mask) == 0,
(black.liberty() & DirectionTraits<UL>::mask) == 0,
(black.liberty() & DirectionTraits<L>::mask) == 0),
result);
}
King8Info white(state.Iking8Info(WHITE));
if ((white.liberty() & (DirectionTraits<UL>::mask |
DirectionTraits<L>::mask |
DirectionTraits<DL>::mask)) == 0)
{
adjust<-1>(
indexY<WHITE>(state.kingSquare<WHITE>(),
true,
(white.liberty() & DirectionTraits<U>::mask) == 0,
(white.liberty() & DirectionTraits<UR>::mask) == 0,
(white.liberty() & DirectionTraits<R>::mask) == 0),
result);
}
if ((white.liberty() & (DirectionTraits<UR>::mask |
DirectionTraits<R>::mask |
DirectionTraits<DR>::mask)) == 0)
{
adjust<-1>(
indexY<WHITE>(state.kingSquare<WHITE>(),
false,
(white.liberty() & DirectionTraits<U>::mask) == 0,
(white.liberty() & DirectionTraits<UL>::mask) == 0,
(white.liberty() & DirectionTraits<L>::mask) == 0),
result);
}
return result;
}
␌
osl::CArray<MultiInt, 4> osl::eval::ml::AnagumaEmpty::table;
void osl::eval::ml::
AnagumaEmpty::setUp(const Weights &weights,int stage)
{
for (size_t i = 0; i < table.size(); ++i)
{
table[i][stage] = weights.value(i);
}
}
int osl::eval::ml::AnagumaEmpty::index(
Square king, Square target)
{
return std::abs(king.x() - target.x()) + std::abs(king.y() - target.y()) * 2;
}
template <osl::Player Defense>
MultiInt osl::eval::ml::AnagumaEmpty::evalOne(const NumEffectState &state)
{
MultiInt result;
const Square king = state.kingSquare<Defense>();
if ((king.x() == 1 || king.x() == 9) &&
((Defense == BLACK && king.y() == 9) ||
(Defense == WHITE && king.y() == 1))){
const int x = (king.x() == 1 ? 2 : 8);
const int y = (Defense == BLACK ? 8 : 2);
if(Defense==BLACK){
if (state.pieceAt(Square(king.x(), y)).isEmpty())
result +=table[index(king, Square(king.x(), y))];
if (state.pieceAt(Square(x, y)).isEmpty())
result +=table[index(king, Square(x, y))];
if (state.pieceAt(Square(x, king.y())).isEmpty())
result +=table[index(king, Square(x, king.y()))];
}
else{
if (state.pieceAt(Square(king.x(), y)).isEmpty())
result -=table[index(king, Square(king.x(), y))];
if (state.pieceAt(Square(x, y)).isEmpty())
result -=table[index(king, Square(x, y))];
if (state.pieceAt(Square(x, king.y())).isEmpty())
result -=table[index(king, Square(x, king.y()))];
}
}
return result;
}
MultiInt osl::eval::ml::
AnagumaEmpty::eval(const NumEffectState &state)
{
return evalOne<BLACK>(state) + evalOne<WHITE>(state);
}
␌
namespace osl
{
namespace eval
{
namespace ml
{
template class King8EffectEmptySquare<true>;
template class King8EffectEmptySquare<false>;
template class King8EffectDefenseSquare<true>;
template class King8EffectDefenseSquare<false>;
}
}
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::CArray
Definition container.h:20
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
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::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::NumEffectState::changedEffects
const BoardMask changedEffects(Player pl) const
Definition numEffectState.h:144
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::Iking8Info
uint64_t Iking8Info(Player king) const
Definition numEffectState.h:78
osl::PieceMask
駒番号のビットセット.
Definition pieceMask.h:21
osl::Piece
駒.
Definition basic_type.h:788
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::isOnBoardByOwner
bool isOnBoardByOwner() const
piece がプレイヤーPの持ち物でかつボード上にある駒の場合は true.
Definition basic_type.h:852
osl::SimpleState::kingPiece
const Piece kingPiece() const
Definition simpleState.h:83
osl::SimpleState::kingSquare
Square kingSquare() const
Definition simpleState.h:94
osl::SimpleState::pieceAt
const Piece pieceAt(Square sq) const
Definition simpleState.h:167
osl::Square
Definition basic_type.h:532
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
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::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::container::BoardMask
11 x 12
Definition boardMask.h:21
osl::container::BoardMask::set
void set(unsigned int i)
Definition boardMask.h:40
osl::container::BoardMask::anyInRange
bool anyInRange(const BoardMask &mask) const
Definition boardMask.h:57
osl::eval::ml::AnagumaEmpty::evalOne
static MultiInt evalOne(const NumEffectState &state)
Definition king8.cc:1043
osl::eval::ml::AnagumaEmpty::setUp
static void setUp(const Weights &weights, int stage)
Definition king8.cc:1027
osl::eval::ml::AnagumaEmpty::table
static CArray< MultiInt, 4 > table
Definition core/osl/eval/king8.h:367
osl::eval::ml::AnagumaEmpty::index
static int index(Square king, Square target)
Definition king8.cc:1036
osl::eval::ml::AnagumaEmpty::eval
static MultiInt eval(const NumEffectState &state)
Definition king8.cc:1073
osl::eval::ml::King8EffectAll::l_defense_piece_table
static CArray< int, ONE_DIM > l_defense_piece_table
Definition core/osl/eval/king8.h:157
osl::eval::ml::King8EffectAll::d_defense_piece_table
static CArray< int, ONE_DIM > d_defense_piece_table
Definition core/osl/eval/king8.h:156
osl::eval::ml::King8EffectAll::d_table
static CArray< int, ONE_DIM > d_table
Definition core/osl/eval/king8.h:151
osl::eval::ml::King8EffectAll::EffectState
EffectState
Definition core/osl/eval/king8.h:161
osl::eval::ml::King8EffectAll::NO_EFFECT
@ NO_EFFECT
Definition core/osl/eval/king8.h:163
osl::eval::ml::King8EffectAll::LESS_EFFECT
@ LESS_EFFECT
Definition core/osl/eval/king8.h:164
osl::eval::ml::King8EffectAll::MORE_EFFECT
@ MORE_EFFECT
Definition core/osl/eval/king8.h:165
osl::eval::ml::King8EffectAll::MORE_EFFECT_KING_ONLY
@ MORE_EFFECT_KING_ONLY
Definition core/osl/eval/king8.h:166
osl::eval::ml::King8EffectAll::NOT_EMPTY
@ NOT_EMPTY
Definition core/osl/eval/king8.h:162
osl::eval::ml::King8EffectAll::u_table
static CArray< int, ONE_DIM > u_table
Definition core/osl/eval/king8.h:150
osl::eval::ml::King8EffectAll::r_table
static CArray< int, ONE_DIM > r_table
Definition core/osl/eval/king8.h:153
osl::eval::ml::King8EffectAll::u_defense_piece_table
static CArray< int, ONE_DIM > u_defense_piece_table
Definition core/osl/eval/king8.h:155
osl::eval::ml::King8EffectAll::base_defense_piece_table
static CArray< int, ONE_DIM > base_defense_piece_table
Definition core/osl/eval/king8.h:154
osl::eval::ml::King8EffectAll::eval
static int eval(const NumEffectState &state, PieceMask black_mask, PieceMask white_mask)
Definition king8.cc:487
osl::eval::ml::King8EffectAll::r_defense_piece_table
static CArray< int, ONE_DIM > r_defense_piece_table
Definition core/osl/eval/king8.h:158
osl::eval::ml::King8EffectAll::setUp
static void setUp(const Weights &weights)
Definition king8.cc:408
osl::eval::ml::King8EffectAll::index
static int index(const Direction dir, EffectState state)
Definition king8.cc:481
osl::eval::ml::King8EffectAll::l_table
static CArray< int, ONE_DIM > l_table
Definition core/osl/eval/king8.h:152
osl::eval::ml::King8EffectAll::ONE_DIM
@ ONE_DIM
Definition core/osl/eval/king8.h:147
osl::eval::ml::King8EffectAll::base_table
static CArray< int, ONE_DIM > base_table
Definition core/osl/eval/king8.h:149
osl::eval::ml::King8EffectAll::effectState
static void effectState(const NumEffectState &state, const Player defense, const Direction dir, EffectState &empty, EffectState &)
Definition king8.cc:436
osl::eval::ml::King8EffectBase
Definition core/osl/eval/king8.h:51
osl::eval::ml::King8EffectBase::EffectState
EffectState
Definition core/osl/eval/king8.h:56
osl::eval::ml::King8EffectBase::NOT_EMPTY
@ NOT_EMPTY
Definition core/osl/eval/king8.h:57
osl::eval::ml::King8EffectBase::MORE_EFFECT_KING_ONLY
@ MORE_EFFECT_KING_ONLY
Definition core/osl/eval/king8.h:61
osl::eval::ml::King8EffectBase::LESS_EFFECT
@ LESS_EFFECT
Definition core/osl/eval/king8.h:59
osl::eval::ml::King8EffectBase::MORE_EFFECT
@ MORE_EFFECT
Definition core/osl/eval/king8.h:60
osl::eval::ml::King8EffectBase::NO_EFFECT
@ NO_EFFECT
Definition core/osl/eval/king8.h:58
osl::eval::ml::King8EffectBase::evalCommon
static const CArray< int, 2 > evalCommon(const NumEffectState &state, const table_t &)
osl::eval::ml::King8EffectBase::table_t
CArray< int, 32 > table_t
Definition core/osl/eval/king8.h:54
osl::eval::ml::King8EffectBase::index
static int index(const Direction dir, EffectState state)
Definition core/osl/eval/king8.h:78
osl::eval::ml::King8EffectBase::evalWithUpdateCommon
static const CArray< int, 2 > evalWithUpdateCommon(const NumEffectState &new_state, Move last_move, const CArray< int, 2 > &last_value, const table_t &)
osl::eval::ml::King8EffectDefenseSquareBoth::evalWithUpdate
static std::pair< CArray< int, 2 >, CArray< int, 2 > > evalWithUpdate(const NumEffectState &new_state, Move last_move, const CArray< int, 2 > &last_value_opening, const CArray< int, 2 > &last_value_ending)
Definition king8.cc:374
osl::eval::ml::King8EffectDefenseSquare
Definition core/osl/eval/king8.h:117
osl::eval::ml::King8EffectDefenseSquare::evalWithUpdate
static const CArray< int, 2 > evalWithUpdate(const NumEffectState &new_state, Move last_move, const CArray< int, 2 > &last_value)
Definition king8.cc:364
osl::eval::ml::King8EffectDefenseSquare::setUp
static void setUp(const Weights &weights)
Definition king8.cc:348
osl::eval::ml::King8EffectDefenseSquare::table
static CArray< int, 32 > table
Definition core/osl/eval/king8.h:119
osl::eval::ml::King8EffectDefenseSquare::eval
static const CArray< int, 2 > eval(const NumEffectState &state)
Definition king8.cc:358
osl::eval::ml::King8EffectEmptySquareBoth::evalWithUpdate
static std::pair< CArray< int, 2 >, CArray< int, 2 > > evalWithUpdate(const NumEffectState &new_state, Move last_move, const CArray< int, 2 > &last_value_opening, const CArray< int, 2 > &last_value_ending)
Definition king8.cc:336
osl::eval::ml::King8EffectEmptySquare
Definition core/osl/eval/king8.h:86
osl::eval::ml::King8EffectEmptySquare::eval
static const CArray< int, 2 > eval(const NumEffectState &state)
Definition king8.cc:321
osl::eval::ml::King8EffectEmptySquare::table
static table_t table
Definition core/osl/eval/king8.h:88
osl::eval::ml::King8EffectEmptySquare::evalWithUpdate
static const CArray< int, 2 > evalWithUpdate(const NumEffectState &new_state, Move last_move, const CArray< int, 2 > &last_value)
Definition king8.cc:327
osl::eval::ml::King8EffectEmptySquare::setUp
static void setUp(const Weights &weights)
Definition king8.cc:310
osl::eval::ml::King8Effect::defense_table
static CArray< int, 32 > defense_table
Definition core/osl/eval/king8.h:34
osl::eval::ml::King8Effect::indexY
static int indexY(Piece king, const Direction dir, EffectState state)
Definition king8.cc:89
osl::eval::ml::King8Effect::eval
static int eval(const NumEffectState &state)
Definition king8.cc:40
osl::eval::ml::King8Effect::empty_y_table
static CArray< int, 288 > empty_y_table
Definition core/osl/eval/king8.h:35
osl::eval::ml::King8Effect::empty_table
static CArray< int, 32 > empty_table
Definition core/osl/eval/king8.h:33
osl::eval::ml::King8Effect::setUp
static void setUp(const Weights &weights)
Definition king8.cc:17
osl::eval::ml::King8Effect::EffectState
EffectState
Definition core/osl/eval/king8.h:26
osl::eval::ml::King8Effect::NOT_EMPTY
@ NOT_EMPTY
Definition core/osl/eval/king8.h:27
osl::eval::ml::King8Effect::NO_EFFECT
@ NO_EFFECT
Definition core/osl/eval/king8.h:28
osl::eval::ml::King8Effect::index
static int index(const Direction dir, EffectState state)
Definition king8.cc:82
osl::eval::ml::King8Effect::effectState
static void effectState(const NumEffectState &state, const Player defense, const Direction dir, EffectState &empty, EffectState &)
Definition king8.cc:101
osl::eval::ml::King8Effect::defense_y_table
static CArray< int, 288 > defense_y_table
Definition core/osl/eval/king8.h:36
osl::eval::ml::KingXBlocked3Y::setUp
static void setUp(const Weights &weights)
Definition king8.cc:945
osl::eval::ml::KingXBlocked3Y::ONE_DIM
@ ONE_DIM
Definition core/osl/eval/king8.h:353
osl::eval::ml::KingXBlocked3::ONE_DIM
@ ONE_DIM
Definition core/osl/eval/king8.h:294
osl::eval::ml::KingXBlocked3::table
static CArray< MultiInt, 80 > table
Definition core/osl/eval/king8.h:346
osl::eval::ml::KingXBlocked3::y_table
static CArray< MultiInt, 720 > y_table
Definition core/osl/eval/king8.h:347
osl::eval::ml::KingXBlocked3::setUp
static void setUp(const Weights &weights)
Definition king8.cc:936
osl::eval::ml::KingXBlocked3::adjust
static void adjust(int index_y, MultiInt &result)
Definition core/osl/eval/king8.h:299
osl::eval::ml::KingXBlocked3::eval
static MultiInt eval(const NumEffectState &state)
Definition king8.cc:965
osl::eval::ml::KingXBlocked3::indexY
static int indexY(const Square king, bool is_l, bool u_blocked, bool opp_u_blocked, bool opp_blocked)
Definition core/osl/eval/king8.h:326
osl::eval::ml::KingXBlockedBoth::evalWithUpdateBang
static void evalWithUpdateBang(const NumEffectState &new_state, Move last_move, MultiIntPair &last_values_and_out)
Definition king8.cc:916
osl::eval::ml::KingXBlockedYBase::table_t
CArray< MultiInt, 90 > table_t
Definition core/osl/eval/king8.h:219
osl::eval::ml::KingXBlockedYBase::evalWithUpdateBang
static void evalWithUpdateBang(const NumEffectState &state, Move laste_move, MultiIntPair &last_values_and_out)
Definition king8.cc:824
osl::eval::ml::KingXBlockedYBase::index
static int index(Square king, int diff)
Definition king8.cc:879
osl::eval::ml::KingXBlockedYBase::eval
static const MultiIntPair eval(const NumEffectState &state, const table_t &table)
Definition king8.cc:743
osl::eval::ml::KingXBlockedYBase::adjust
static void adjust(int index, int index_y, MultiInt &out)
Definition king8.cc:813
osl::eval::ml::KingXBlockedY::table
static table_t table
Definition core/osl/eval/king8.h:243
osl::eval::ml::KingXBlockedY::setUp
static void setUp(const Weights &weights, int stage)
Definition king8.cc:924
osl::eval::ml::KingXBlocked::setUp
static void setUp(const Weights &weights, int stage)
Definition king8.cc:907
osl::eval::ml::KingXBlocked::table
static table_t table
Definition core/osl/eval/king8.h:212
osl::eval::ml::KingXBothBlockedY::table
static CArray< MultiInt, ONE_DIM > table
Definition core/osl/eval/king8.h:287
osl::eval::ml::KingXBothBlockedY::setUp
static void setUp(const Weights &weights)
Definition king8.cc:613
osl::eval::ml::KingXBothBlockedY::ONE_DIM
@ ONE_DIM
Definition core/osl/eval/king8.h:284
osl::eval::ml::KingXBothBlocked::adjust
static void adjust(int index, int index_y, MultiInt &out)
Definition king8.cc:625
osl::eval::ml::KingXBothBlocked::indexY
static int indexY(const Square king)
Definition core/osl/eval/king8.h:269
osl::eval::ml::KingXBothBlocked::eval
static MultiIntPair eval(const NumEffectState &state)
Definition king8.cc:634
osl::eval::ml::KingXBothBlocked::table
static CArray< MultiInt, ONE_DIM > table
Definition core/osl/eval/king8.h:262
osl::eval::ml::KingXBothBlocked::setUp
static void setUp(const Weights &weights)
Definition king8.cc:603
osl::eval::ml::KingXBothBlocked::ONE_DIM
@ ONE_DIM
Definition core/osl/eval/king8.h:258
osl::eval::ml::KingXBothBlocked::index
static int index(const Square king)
Definition core/osl/eval/king8.h:263
king8.h
osl::eval::ml
Definition eval_pieceStand.cc:470
osl::eval
Definition eval_pieceStand.cc:468
osl
Definition additionalEffect.h:6
osl::indexToPlayer
constexpr Player indexToPlayer(int n)
Definition basic_type.h:19
osl::MultiIntPair
QuadIntPair MultiIntPair
Definition midgame.h:14
osl::playerToIndex
constexpr int playerToIndex(Player player)
Definition basic_type.h:16
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::SHORT8_DIRECTION_MIN
@ SHORT8_DIRECTION_MIN
Definition basic_type.h:312
osl::SHORT8_DIRECTION_MAX
@ SHORT8_DIRECTION_MAX
Definition basic_type.h:321
osl::Board_Mask_Table3x3
const BoardMaskTable3x3 Board_Mask_Table3x3
Definition tables.cc:120
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::__attribute__
const PtypeO PTYPEO_EDGE __attribute__((unused))
osl::alt
constexpr Player alt(Player player)
Definition basic_type.h:13
osl::DirectionTraits::mask
static const unsigned int mask
Definition directionTraits.h:227
osl::eval::ml::King8EffectBase::MakeEffectStateDefense
Definition king8.cc:180
osl::eval::ml::King8EffectBase::MakeEffectStateDefense::operator()
EffectState operator()(const NumEffectState &state, const Player defense, const Direction dir) const
Definition king8.cc:181
osl::eval::ml::King8EffectBase::MakeEffectStateSimple
Definition king8.cc:153
osl::eval::ml::King8EffectBase::MakeEffectStateSimple::operator()
EffectState operator()(const NumEffectState &state, const Player defense, const Direction dir) const
Definition king8.cc:154
osl::eval::ml::KingXBlockedBase::table_t
CArray< MultiInt, 10 > table_t
Definition core/osl/eval/king8.h:183
osl::eval::ml::KingXBlockedBase::isBlocked
static bool isBlocked(const NumEffectState &state, int diff)
Definition king8.cc:692
osl::eval::ml::KingXBlockedBase::index
static int index(Square king, int diff)
Definition king8.cc:669
osl::eval::ml::KingXBlockedBase::eval
static const MultiIntPair eval(const NumEffectState &state, const table_t &table)
Definition king8.cc:724
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