additionalOrShadow.h
Go to the documentation of this file.
/* additionalOrShadow.h
*/
#ifndef OSL_ADDITIONALORSHADOW_H
#define OSL_ADDITIONALORSHADOW_H
#include "osl/numEffectState.h"
#include "osl/bits/boardTable.h"
namespace osl
{
namespace effect_util
{
struct AdditionalOrShadow
{
template <int count_max>
static int count(const PieceVector& direct_pieces,
const NumEffectState& state,
Square target, Player attack)
{
int result=0;
for (Piece p: direct_pieces)
{
const Square from = p.square();
int num = p.number();
const Direction long_d=Board_Table.getLongDirection<BLACK>(Offset32(target,from));
if(!isLong(long_d)) continue; // unpromoted Knightを除いておくのとどちらが得か?
Direction d=longToShort(long_d);
for(;;){
num=state.longEffectNumTable()[num][d];
if(Piece::isEmptyNum(num) || state.pieceOf(num).owner()!=attack)
break;
if (++result >= count_max)
return result;
}
}
return result;
}
};
}
} // namespace osl
#endif /* OSL_ADDITIONALORSHADOW_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; coding:utf-8
// ;;; End:
boardTable.h
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::NumEffectState::longEffectNumTable
const EffectedNumTable & longEffectNumTable() const
Definition numEffectState.h:124
osl::PieceVector
Definition container.h:305
osl::Piece
駒.
Definition basic_type.h:788
osl::Piece::owner
Player owner() const
Definition basic_type.h:963
osl::Piece::isEmptyNum
static bool isEmptyNum(int num)
Definition basic_type.h:916
osl::SimpleState::pieceOf
const Piece pieceOf(int num) const
Definition simpleState.h:76
osl::Square
Definition basic_type.h:532
osl::Square::square
unsigned int square
Definition basic_type.h:533
osl::effect_util
Definition additionalEffect.h:8
osl
Definition additionalEffect.h:6
osl::longToShort
constexpr Direction longToShort(Direction d)
Definition basic_type.h:380
osl::Board_Table
const BoardTable Board_Table
Definition tables.cc:95
osl::Direction
Direction
Definition basic_type.h:310
osl::Offset32
Offset32Base< 8, 9 > Offset32
Definition offset32.h:63
osl::Player
Player
Definition basic_type.h:8
osl::BLACK
@ BLACK
Definition basic_type.h:9
osl::isLong
constexpr bool isLong(Direction d)
Definition basic_type.h:350
numEffectState.h
osl::effect_util::AdditionalOrShadow
Definition additionalOrShadow.h:14
osl::effect_util::AdditionalOrShadow::count
static int count(const PieceVector &direct_pieces, const NumEffectState &state, Square target, Player attack)
Definition additionalOrShadow.h:16