mobility.h
Go to the documentation of this file.
/* mobility.h
*/
#ifndef EVAL_ML_MOBILITY_H
#define EVAL_ML_MOBILITY_H
#include "osl/eval/weights.h"
#include "osl/eval/midgame.h"
#include "osl/numEffectState.h"
namespace osl
{
namespace eval
{
namespace ml
{
class RookMobilityAll
{
friend class RookMobility;
friend class RookMobilityX;
friend class RookMobilityY;
friend class RookMobilitySum;
friend class RookMobilitySumKingX;
friend class RookMobilityXKingX;
public:
template<int Sign>
static void adjust(const NumEffectState&, bool promoted,
int vertical, int horizontal,
Square pos,
MultiInt& value);
static void eval(const NumEffectState&, MultiInt& out);
private:
static int indexX(Square rook, bool promoted,
int count, bool vertical)
{
const int x = (rook.x() > 5 ?
10 - rook.x() : rook.x());
return x - 1 + 5 * ((promoted ? 1 : 0) +
2 * ((vertical ? 1 : 0) + 2 * count));
}
template <int Sign>
static int indexY(Square rook, bool promoted,
int count, bool vertical)
{
const int y = (Sign > 0 ? rook.y() : 10 - rook.y());
return y - 1 + 9 * ((promoted ? 1 : 0) +
2 * ((vertical ? 1 : 0) + 2 * count));
}
template <int Sign>
static int indexXKingX(Square rook, Square king, int count, bool vertical)
{
const Square r = (Sign > 0) ? rook : rook.rotate180();
const Square k = (Sign > 0) ? king : king.rotate180();
const bool flip = r.x() > 5;
const int x = (flip ? 10 - r.x() : r.x());
const int king_x = (flip ? 10 - k.x() : k.x());
return king_x - 1 + 9 * (x - 1 + 5 * ((vertical ? 1 : 0) + 2 * count));
}
static CArray<MultiInt, 18> rook_vertical_table;
static CArray<MultiInt, 18> rook_horizontal_table;
static CArray<MultiInt, 34> sum_table;
static CArray<MultiInt, 324> x_table;
static CArray<MultiInt, 324> y_table;
static CArray<MultiInt, 17 * 9> sumkingx_table;
static CArray<MultiInt, 9 * 2 * 5 * 9> xkingx_table;
};
class RookMobility
{
public:
enum { DIM = 36 };
static void setUp(const Weights &weights,int stage);
};
class RookMobilitySum
{
public:
enum { ONE_DIM = 34, DIM = ONE_DIM * EvalStages };
static void setUp(const Weights &weights);
};
class RookMobilityX
{
public:
enum { ONE_DIM = 180, DIM = ONE_DIM * EvalStages };
static void setUp(const Weights &weights);
};
class RookMobilityY
{
public:
enum { ONE_DIM = 324, DIM = ONE_DIM * EvalStages };
static void setUp(const Weights &weights);
};
class RookMobilitySumKingX
{
public:
enum { ONE_DIM = 17 * 9, DIM = ONE_DIM * EvalStages };
static void setUp(const Weights &weights);
};
class RookMobilityXKingX
{
public:
enum { ONE_DIM = 9 * 2 * 5 * 9, DIM = ONE_DIM * EvalStages };
static void setUp(const Weights &weights);
};
struct BishopMobilityAll
{
friend class BishopMobility;
friend class BishopMobilityEach;
public:
template<int Sign>
static void adjust(bool promoted, int mobility1, int mobility2,
MultiInt& value);
static void eval(const NumEffectState&, MultiInt& out);
private:
static CArray<MultiInt, 36> bishop_table;
static CArray<MultiInt, 18> each_table;
};
class BishopMobility
{
public:
enum { DIM = 36 };
static void setUp(const Weights &weights,int stage);
};
class BishopMobilityEach
{
public:
enum { ONE_DIM = 18, DIM = ONE_DIM * EvalStages };
static void setUp(const Weights &weights);
};
struct LanceMobilityAll
{
template<int Sign>
static void adjust(int index, MultiInt& value);
static void eval(const NumEffectState&, MultiInt& out);
};
class LanceMobility
{
static CArray<MultiInt, 9> lance_table;
friend struct LanceMobilityAll;
public:
enum { DIM = 9 };
LanceMobility() { };
static void setUp(const Weights &weights,int stage);
};
}
}
}
#endif // EVAL_ML_MOBILITY_H
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::CArray
Definition container.h:20
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::Square
Definition basic_type.h:532
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
osl::Square::rotate180
const Square rotate180() const
Definition basic_type.h:613
osl::Square::x
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
osl::eval::ml::BishopMobilityEach
Definition mobility.h:126
osl::eval::ml::BishopMobilityEach::setUp
static void setUp(const Weights &weights)
Definition mobility.cc:189
osl::eval::ml::BishopMobilityEach::DIM
@ DIM
Definition mobility.h:128
osl::eval::ml::BishopMobilityEach::ONE_DIM
@ ONE_DIM
Definition mobility.h:128
osl::eval::ml::BishopMobility
Definition mobility.h:120
osl::eval::ml::BishopMobility::DIM
@ DIM
Definition mobility.h:122
osl::eval::ml::BishopMobility::setUp
static void setUp(const Weights &weights, int stage)
Definition mobility.cc:176
osl::eval::ml::LanceMobility::LanceMobility
LanceMobility()
Definition mobility.h:143
osl::eval::ml::LanceMobility::setUp
static void setUp(const Weights &weights, int stage)
Definition mobility.cc:261
osl::eval::ml::LanceMobility::LanceMobilityAll
friend struct LanceMobilityAll
Definition mobility.h:140
osl::eval::ml::LanceMobility::lance_table
static CArray< MultiInt, 9 > lance_table
Definition mobility.h:139
osl::eval::ml::LanceMobility::DIM
@ DIM
Definition mobility.h:142
osl::eval::ml::RookMobilityAll
Definition mobility.h:18
osl::eval::ml::RookMobilityAll::sum_table
static CArray< MultiInt, 34 > sum_table
Definition mobility.h:61
osl::eval::ml::RookMobilityAll::RookMobility
friend class RookMobility
Definition mobility.h:19
osl::eval::ml::RookMobilityAll::indexX
static int indexX(Square rook, bool promoted, int count, bool vertical)
Definition mobility.h:33
osl::eval::ml::RookMobilityAll::rook_vertical_table
static CArray< MultiInt, 18 > rook_vertical_table
Definition mobility.h:59
osl::eval::ml::RookMobilityAll::indexXKingX
static int indexXKingX(Square rook, Square king, int count, bool vertical)
Definition mobility.h:50
osl::eval::ml::RookMobilityAll::x_table
static CArray< MultiInt, 324 > x_table
Definition mobility.h:62
osl::eval::ml::RookMobilityAll::RookMobilitySumKingX
friend class RookMobilitySumKingX
Definition mobility.h:23
osl::eval::ml::RookMobilityAll::RookMobilitySum
friend class RookMobilitySum
Definition mobility.h:22
osl::eval::ml::RookMobilityAll::indexY
static int indexY(Square rook, bool promoted, int count, bool vertical)
Definition mobility.h:42
osl::eval::ml::RookMobilityAll::RookMobilityXKingX
friend class RookMobilityXKingX
Definition mobility.h:24
osl::eval::ml::RookMobilityAll::y_table
static CArray< MultiInt, 324 > y_table
Definition mobility.h:63
osl::eval::ml::RookMobilityAll::RookMobilityY
friend class RookMobilityY
Definition mobility.h:21
osl::eval::ml::RookMobilityAll::eval
static void eval(const NumEffectState &, MultiInt &out)
Definition mobility.cc:145
osl::eval::ml::RookMobilityAll::RookMobilityX
friend class RookMobilityX
Definition mobility.h:20
osl::eval::ml::RookMobilityAll::sumkingx_table
static CArray< MultiInt, 17 *9 > sumkingx_table
Definition mobility.h:64
osl::eval::ml::RookMobilityAll::rook_horizontal_table
static CArray< MultiInt, 18 > rook_horizontal_table
Definition mobility.h:60
osl::eval::ml::RookMobilityAll::xkingx_table
static CArray< MultiInt, 9 *2 *5 *9 > xkingx_table
Definition mobility.h:65
osl::eval::ml::RookMobilityAll::adjust
static void adjust(const NumEffectState &, bool promoted, int vertical, int horizontal, Square pos, MultiInt &value)
Definition mobility.cc:103
osl::eval::ml::RookMobilitySumKingX
Definition mobility.h:94
osl::eval::ml::RookMobilitySumKingX::setUp
static void setUp(const Weights &weights)
Definition mobility.cc:92
osl::eval::ml::RookMobilitySumKingX::DIM
@ DIM
Definition mobility.h:96
osl::eval::ml::RookMobilitySumKingX::ONE_DIM
@ ONE_DIM
Definition mobility.h:96
osl::eval::ml::RookMobilitySum
Definition mobility.h:76
osl::eval::ml::RookMobilitySum::setUp
static void setUp(const Weights &weights)
Definition mobility.cc:53
osl::eval::ml::RookMobilitySum::ONE_DIM
@ ONE_DIM
Definition mobility.h:78
osl::eval::ml::RookMobilitySum::DIM
@ DIM
Definition mobility.h:78
osl::eval::ml::RookMobilityXKingX
Definition mobility.h:100
osl::eval::ml::RookMobilityXKingX::setUp
static void setUp(const Weights &weights)
Definition mobility.cc:83
osl::eval::ml::RookMobilityXKingX::DIM
@ DIM
Definition mobility.h:102
osl::eval::ml::RookMobilityXKingX::ONE_DIM
@ ONE_DIM
Definition mobility.h:102
osl::eval::ml::RookMobilityX
Definition mobility.h:82
osl::eval::ml::RookMobilityX::ONE_DIM
@ ONE_DIM
Definition mobility.h:84
osl::eval::ml::RookMobilityX::DIM
@ DIM
Definition mobility.h:84
osl::eval::ml::RookMobilityX::setUp
static void setUp(const Weights &weights)
Definition mobility.cc:63
osl::eval::ml::RookMobilityY
Definition mobility.h:88
osl::eval::ml::RookMobilityY::setUp
static void setUp(const Weights &weights)
Definition mobility.cc:73
osl::eval::ml::RookMobilityY::DIM
@ DIM
Definition mobility.h:90
osl::eval::ml::RookMobilityY::ONE_DIM
@ ONE_DIM
Definition mobility.h:90
osl::eval::ml::RookMobility
Definition mobility.h:69
osl::eval::ml::RookMobility::DIM
@ DIM
Definition mobility.h:71
osl::eval::ml::RookMobility::setUp
static void setUp(const Weights &weights, int stage)
Definition mobility.cc:32
midgame.h
osl::eval::ml
Definition eval_pieceStand.cc:470
osl::eval
Definition eval_pieceStand.cc:468
osl
Definition additionalEffect.h:6
osl::MultiInt
QuadInt MultiInt
Definition midgame.h:13
osl::EvalStages
const int EvalStages
Definition midgame.h:12
numEffectState.h
osl::eval::ml::BishopMobilityAll
Definition mobility.h:107
osl::eval::ml::BishopMobilityAll::BishopMobility
friend class BishopMobility
Definition mobility.h:108
osl::eval::ml::BishopMobilityAll::adjust
static void adjust(bool promoted, int mobility1, int mobility2, MultiInt &value)
Definition mobility.cc:200
osl::eval::ml::BishopMobilityAll::BishopMobilityEach
friend class BishopMobilityEach
Definition mobility.h:109
osl::eval::ml::BishopMobilityAll::each_table
static CArray< MultiInt, 18 > each_table
Definition mobility.h:117
osl::eval::ml::BishopMobilityAll::eval
static void eval(const NumEffectState &, MultiInt &out)
Definition mobility.cc:225
osl::eval::ml::BishopMobilityAll::bishop_table
static CArray< MultiInt, 36 > bishop_table
Definition mobility.h:116
osl::eval::ml::LanceMobilityAll
Definition mobility.h:132
osl::eval::ml::LanceMobilityAll::adjust
static void adjust(int index, MultiInt &value)
Definition mobility.cc:271
osl::eval::ml::LanceMobilityAll::eval
static void eval(const NumEffectState &, MultiInt &out)
Definition mobility.cc:280
osl::eval::ml::Weights
Definition weights.h:18
weights.h