effect5x3.h
Go to the documentation of this file.
/* effect5x3.h
*/
#ifndef PROGRESS_EFFECT5X3_H
#define PROGRESS_EFFECT5X3_H
#include "osl/progress.h"
#include "osl/numEffectState.h"
#include "osl/bits/centering5x3.h"
#include "osl/container.h"
#include <algorithm>
namespace osl
{
namespace progress
{
struct Effect5x3
{
public:
static void updateStand(int& old_stand, Move last_move);
static int makeProgressAll(Player defense, const NumEffectState& state,
Square king);
static int makeProgressArea(Player attack, const NumEffectState& state,
Square king);
public:
static int makeProgressStand(Player attack, const NumEffectState& state);
static int makeProgress(Player defense, const NumEffectState& state){
return makeProgressAll(defense,state,state.kingSquare(defense));
}
static int makeProgress(const NumEffectState& state)
{
return makeProgress(BLACK, state) + makeProgress(WHITE, state);
}
static const Progress16 progress16(int progress)
{
assert(progress >= 0);
const int rank = progress / 8; // 適当
return Progress16(std::min(rank, 15));
}
static const Progress16 progress16each(int progress)
{
assert(progress >= 0);
const int rank = progress / 8; // 調整中
return Progress16(std::min(rank, 15));
}
protected:
CArray<int,2> progresses, stand_progresses, area_progresses;
public:
explicit Effect5x3(const NumEffectState& state);
void changeTurn() {}
int progress(Player p) const { return progresses[p]; }
const Progress16 progress16() const
{
return progress16(progresses[0] + progresses[1]);
}
const Progress16 progress16(Player p) const
{
return progress16each(progress(p));
}
// 必要なもの
Effect5x3 expect(const NumEffectState& state, Move move) const;
void update(const NumEffectState& new_state, Move last_move);
};
struct Effect5x3WithBonus : public Effect5x3
{
explicit Effect5x3WithBonus(const NumEffectState& state);
template <Player Attack>
static int makeProgressAreaBonus(const NumEffectState& state,
Square king);
template <Player Attack, bool AlwaysPromotable, bool AlwaysNotPromotable>
static int makeProgressAreaBonus(const NumEffectState& state,
Square king, Square center);
const Progress16 progress16bonus(Player p) const
{
return progress16each(progress_bonuses[p] +
stand_progresses[p]);
}
void update(const NumEffectState& new_state, Move last_move);
Effect5x3WithBonus expect(const NumEffectState& state, Move move) const;
// Public for testing
int countEffectPieces(const NumEffectState &state, Player attack) const;
// p is defense player
const PieceMask effect5x3Mask(Player p) const { return effect_mask[p]; }
private:
void updateProgressBonuses(const NumEffectState& state, bool black=true, bool white=true);
static int attackEffect3(const NumEffectState& state, Player attack, Square target);
template <Player Defense>
static PieceMask makeEffectMask(const NumEffectState& state);
void updateStand(Player pl, Move m) { Effect5x3::updateStand(stand_progresses[pl], m); }
CArray<int,2> progress_bonuses;
CArray<PieceMask, 2> effect_mask;
};
} // namespace progress
} // namespace osl
#endif /* PROGRESS_EFFECT5X3_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
centering5x3.h
osl::CArray
Definition container.h:20
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::PieceMask
駒番号のビットセット.
Definition pieceMask.h:21
osl::SimpleState::kingSquare
Square kingSquare() const
Definition simpleState.h:94
osl::Square
Definition basic_type.h:532
container.h
osl::progress
Definition progress.cc:754
osl::progress::Progress16
ProgressN< 16 > Progress16
Definition progress.h:42
osl
Definition additionalEffect.h:6
osl::Player
Player
Definition basic_type.h:8
osl::WHITE
@ WHITE
Definition basic_type.h:10
osl::BLACK
@ BLACK
Definition basic_type.h:9
numEffectState.h
progress.h
osl::progress::Effect5x3WithBonus
Definition effect5x3.h:89
osl::progress::Effect5x3WithBonus::countEffectPieces
int countEffectPieces(const NumEffectState &state, Player attack) const
Definition effect5x3.cc:364
osl::progress::Effect5x3WithBonus::progress16bonus
const Progress16 progress16bonus(Player p) const
Definition effect5x3.h:97
osl::progress::Effect5x3WithBonus::updateStand
void updateStand(Player pl, Move m)
Definition effect5x3.h:113
osl::progress::Effect5x3WithBonus::Effect5x3WithBonus
Effect5x3WithBonus(const NumEffectState &state)
Definition effect5x3.cc:113
osl::progress::Effect5x3WithBonus::attackEffect3
static int attackEffect3(const NumEffectState &state, Player attack, Square target)
Definition effect5x3.cc:148
osl::progress::Effect5x3WithBonus::expect
Effect5x3WithBonus expect(const NumEffectState &state, Move move) const
Definition effect5x3.cc:332
osl::progress::Effect5x3WithBonus::makeProgressAreaBonus
static int makeProgressAreaBonus(const NumEffectState &state, Square king)
Definition effect5x3.cc:292
osl::progress::Effect5x3WithBonus::updateProgressBonuses
void updateProgressBonuses(const NumEffectState &state, bool black=true, bool white=true)
Definition effect5x3.cc:345
osl::progress::Effect5x3WithBonus::makeEffectMask
static PieceMask makeEffectMask(const NumEffectState &state)
osl::progress::Effect5x3WithBonus::update
void update(const NumEffectState &new_state, Move last_move)
Definition effect5x3.cc:307
osl::progress::Effect5x3WithBonus::effect_mask
CArray< PieceMask, 2 > effect_mask
Definition effect5x3.h:116
osl::progress::Effect5x3WithBonus::progress_bonuses
CArray< int, 2 > progress_bonuses
Definition effect5x3.h:115
osl::progress::Effect5x3WithBonus::effect5x3Mask
const PieceMask effect5x3Mask(Player p) const
Definition effect5x3.h:107
osl::progress::Effect5x3
玉の周囲5x3の領域の利きの数と持駒から計算した進行度.
Definition effect5x3.h:27
osl::progress::Effect5x3::makeProgressStand
static int makeProgressStand(Player attack, const NumEffectState &state)
Definition effect5x3.cc:50
osl::progress::Effect5x3::progresses
CArray< int, 2 > progresses
Definition effect5x3.h:71
osl::progress::Effect5x3::progress
int progress(Player p) const
Definition effect5x3.h:75
osl::progress::Effect5x3::progress16
const Progress16 progress16() const
Definition effect5x3.h:76
osl::progress::Effect5x3::makeProgress
static int makeProgress(const NumEffectState &state)
Definition effect5x3.h:47
osl::progress::Effect5x3::progress16
const Progress16 progress16(Player p) const
Definition effect5x3.h:80
osl::progress::Effect5x3::area_progresses
CArray< int, 2 > area_progresses
Definition effect5x3.h:71
osl::progress::Effect5x3::stand_progresses
CArray< int, 2 > stand_progresses
Definition effect5x3.h:71
osl::progress::Effect5x3::makeProgressArea
static int makeProgressArea(Player attack, const NumEffectState &state, Square king)
Definition effect5x3.cc:26
osl::progress::Effect5x3::update
void update(const NumEffectState &new_state, Move last_move)
Definition effect5x3.cc:80
osl::progress::Effect5x3::progress16each
static const Progress16 progress16each(int progress)
0-15 の値を返す.
Definition effect5x3.h:64
osl::progress::Effect5x3::updateStand
static void updateStand(int &old_stand, Move last_move)
Definition effect5x3.cc:65
osl::progress::Effect5x3::Effect5x3
Effect5x3(const NumEffectState &state)
Definition effect5x3.cc:7
osl::progress::Effect5x3::changeTurn
void changeTurn()
Definition effect5x3.h:74
osl::progress::Effect5x3::progress16
static const Progress16 progress16(int progress)
0-15 の値を返す
Definition effect5x3.h:54
osl::progress::Effect5x3::makeProgress
static int makeProgress(Player defense, const NumEffectState &state)
王の位置を指定したprogressの計算.
Definition effect5x3.h:44
osl::progress::Effect5x3::expect
Effect5x3 expect(const NumEffectState &state, Move move) const
Definition effect5x3.cc:98
osl::progress::Effect5x3::makeProgressAll
static int makeProgressAll(Player defense, const NumEffectState &state, Square king)
Definition effect5x3.cc:18