piecePairKing.h
Go to the documentation of this file.
/* piecePairKing.h
*/
#ifndef OSL_EVAL_ML_PIECEPAIRKING_H
#define OSL_EVAL_ML_PIECEPAIRKING_H
#include "osl/numEffectState.h"
namespace osl
{
namespace eval
{
namespace ml
{
struct Weights;
class PiecePairKing
{
public:
enum
{
ONE_DIM = 1488375,
DIM = ONE_DIM
};
static void setUp(const Weights &weights);
static CArray<int,2> eval(const NumEffectState&);
template <Player P>
static void evalWithUpdateBang(const NumEffectState& state, Move moved, CArray<int,2>& last_value);
template <Player King>
static int evalOne(const NumEffectState&);
private:
template <Player King>
static int add(const NumEffectState& state, Square to, Ptype ptype);
template <Player King>
static int sub(const NumEffectState& state, Square from, Ptype ptype);
template <Player King>
static int addSub(const NumEffectState& state, Square to, Ptype ptype, Square from);
static int composeIndex(int king, int i0, int i1)
{
return king + i0*45*7 + i1;
}
static int indexWhite(Square p)
{
return p.x()-1 + (p.y()-1)*9;
}
static int indexKing(Player owner, Square king, bool& flipx)
{
if (owner == BLACK)
king = king.rotate180();
assert(king.y() <= 3);
if (king.x() > 5)
{
king = king.flipHorizontal();
flipx = true;
}
else
flipx = false;
return (king.x()-1 + (king.y()-1)*5)*45*7*45*7;
}
template <bool FlipX>
static int indexPiece(Player owner, Square position, Ptype ptype)
{
assert(! isPromoted(ptype));
if (owner == BLACK)
position = position.rotate180();
if (FlipX)
position = position.flipHorizontal();
assert(position.y() <= 5);
return indexWhite(position)*7 + ptype-PTYPE_BASIC_MIN-1;
}
static osl::CArray<int16_t, ONE_DIM> table;
};
}
}
}
#endif /* OSL_EVAL_ML_PIECEPAIRKING_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::CArray
Definition container.h:20
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
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::Square::flipHorizontal
const Square flipHorizontal() const
Definition basic_type.h:628
osl::eval::ml::PiecePairKing
Definition piecePairKing.h:15
osl::eval::ml::PiecePairKing::indexWhite
static int indexWhite(Square p)
Definition piecePairKing.h:40
osl::eval::ml::PiecePairKing::add
static int add(const NumEffectState &state, Square to, Ptype ptype)
Definition piecePairKing.cc:87
osl::eval::ml::PiecePairKing::setUp
static void setUp(const Weights &weights)
Definition piecePairKing.cc:10
osl::eval::ml::PiecePairKing::addSub
static int addSub(const NumEffectState &state, Square to, Ptype ptype, Square from)
Definition piecePairKing.cc:165
osl::eval::ml::PiecePairKing::evalWithUpdateBang
static void evalWithUpdateBang(const NumEffectState &state, Move moved, CArray< int, 2 > &last_value)
Definition piecePairKing.cc:214
osl::eval::ml::PiecePairKing::composeIndex
static int composeIndex(int king, int i0, int i1)
Definition piecePairKing.h:36
osl::eval::ml::PiecePairKing::evalOne
static int evalOne(const NumEffectState &)
Definition piecePairKing.cc:39
osl::eval::ml::PiecePairKing::table
static osl::CArray< int16_t, ONE_DIM > table
Definition piecePairKing.h:69
osl::eval::ml::PiecePairKing::DIM
@ DIM
Definition piecePairKing.h:20
osl::eval::ml::PiecePairKing::ONE_DIM
@ ONE_DIM
Definition piecePairKing.h:19
osl::eval::ml::PiecePairKing::sub
static int sub(const NumEffectState &state, Square from, Ptype ptype)
Definition piecePairKing.cc:127
osl::eval::ml::PiecePairKing::indexKing
static int indexKing(Player owner, Square king, bool &flipx)
Definition piecePairKing.h:44
osl::eval::ml::PiecePairKing::indexPiece
static int indexPiece(Player owner, Square position, Ptype ptype)
Definition piecePairKing.h:59
osl::eval::ml
Definition eval_pieceStand.cc:470
osl::eval
Definition eval_pieceStand.cc:468
osl
Definition additionalEffect.h:6
osl::Ptype
Ptype
駒の種類を4ビットでコード化する
Definition basic_type.h:84
osl::PTYPE_BASIC_MIN
@ PTYPE_BASIC_MIN
Definition basic_type.h:103
osl::isPromoted
bool isPromoted(Ptype ptype)
ptypeがpromote後の型かどうかのチェック
Definition basic_type.h:137
osl::Player
Player
Definition basic_type.h:8
osl::BLACK
@ BLACK
Definition basic_type.h:9
numEffectState.h
osl::eval::ml::Weights
Definition weights.h:18