/usr/include/osl/mobility/lanceMobility.h is in libosl-dev 0.8.0-1.4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | /* lanceMobility.h
*/
#ifndef MOBILITY_LANCE_MOBILITY_H
#define MOBILITY_LANCE_MOBILITY_H
#include "osl/mobility/countMobility.h"
namespace osl
{
namespace mobility
{
/**
* 盤上の香車の動けるマス
*/
struct LanceMobility
{
public:
/**
* 縦方向,
* P : 駒pの持ち主
* countAll : 利きに関係なく動けるマス
* countSafe : 相手の利きがない動けるマス
* 両方を求める
*/
template<Player P>
static void countBoth(const NumEffectState& state,Piece p,int& countAll,int& countSafe){
assert(p.ptype()==LANCE);
assert(p.isOnBoard());
assert(p.owner()==P);
const Square pos=p.square();
countMobilityBoth(P,state,pos,DirectionPlayerTraits<U,P>::offset(),countAll,countSafe);
}
static void countBoth(Player pl,const NumEffectState& state,Piece p,int& countAll,int &countSafe){
if(pl==BLACK)
countBoth<BLACK>(state,p,countAll,countSafe);
else
countBoth<WHITE>(state,p,countAll,countSafe);
}
/**
* 縦方向,利きに関係なく動けるマスの数
*/
template<Player P>
static int countAll(const NumEffectState& state,Square pos,int num){
const Square pos1=state.mobilityOf(DirectionPlayerTraits<U,P>::directionByBlack,num);
int count=(P==BLACK ? pos.y()-pos1.y() : pos1.y()- pos.y())-1+
(state.pieceAt(pos1).template canMoveOn<P>() ? 1 : 0);
return count;
}
template<Player P>
static int countAll(const NumEffectState& state,Piece p){
assert(p.ptype()==LANCE);
assert(p.isOnBoard());
assert(p.owner()==P);
return countAll<P>(state,p.square(),p.number());
}
static int countAll(Player pl,const NumEffectState& state,Piece p){
if(pl==BLACK)
return countAll<BLACK>(state,p);
else
return countAll<WHITE>(state,p);
}
/**
* 縦方向,相手の利きがない動けるマスを求める
*/
template<Player P>
static int countSafe(const NumEffectState& state,Piece p){
assert(p.ptype()==LANCE);
assert(p.isOnBoard());
assert(p.owner()==P);
const Square pos=p.square();
return
countMobilitySafe(P,state,pos,DirectionPlayerTraits<U,P>::offset());
}
static int countSafe(Player pl,const NumEffectState& state,Piece p){
if(pl==BLACK)
return countSafe<BLACK>(state,p);
else
return countSafe<WHITE>(state,p);
}
};
}
}
#endif /* MOBILITY_LANCE_MOBILITY_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|