/usr/include/osl/mobility/countMobility.h is in libosl-dev 0.6.0-3.
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 | /* countMobility.h
*/
#ifndef MOBILITY_COUNT_MOBILITY_H
#define MOBILITY_COUNT_MOBILITY_H
#include "osl/state/numEffectState.h"
namespace osl
{
namespace mobility
{
/**
* P : 駒pの持ち主
* All : countAllを求めるかどうか?
* Safe : countAllを求めるかどうか?
* countAll : 利きに関係なく動けるマス
* countSafe : 相手の利きがない動けるマス
* 両方を求める
*/
template<Player P,bool All,bool Safe>
inline void countMobilityBoth(const NumEffectState& state,Square pos,Offset o,int& countAll,int& countSafe){
assert(pos.isOnBoard());
assert(!o.zero());
Piece p;
for(pos+=o;(p=state.pieceAt(pos)).isEmpty();pos+=o){
if(All) countAll++;
if(Safe && !state.hasEffectAt<PlayerTraits<P>::opponent>(pos))
countSafe++;
}
if(p.canMoveOn<P>()){
if(All) countAll++;
if(Safe && !state.hasEffectAt<PlayerTraits<P>::opponent>(pos))
countSafe++;
}
}
inline void countMobilityBoth(Player P,const NumEffectState& state,Square pos,Offset o,int& countAll,int& countSafe){
if(P==BLACK)
countMobilityBoth<BLACK,true,true>(state,pos,o,countAll,countSafe);
else
countMobilityBoth<WHITE,true,true>(state,pos,o,countAll,countSafe);
}
/**
* 利きに関係なく動けるマスの数
*/
inline int countMobilityAll(Player pl,const NumEffectState& state,Square pos,Offset o)
{
int ret=0,dummy=0;
if(pl==BLACK)
countMobilityBoth<BLACK,true,false>(state,pos,o,ret,dummy);
else
countMobilityBoth<WHITE,true,false>(state,pos,o,ret,dummy);
return ret;
}
/**
* 相手の利きがない動けるマスを求める
*/
inline int countMobilitySafe(Player pl,const NumEffectState& state,Square pos,Offset o)
{
int ret=0,dummy=0;
if(pl==BLACK)
countMobilityBoth<BLACK,false,true>(state,pos,o,dummy,ret);
else
countMobilityBoth<WHITE,false,true>(state,pos,o,dummy,ret);
return ret;
}
}
}
#endif /* MOBILITY_ROOK_MOBILITY_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|