/usr/include/osl/rating/feature/karanari.h is in libosl-dev 0.6.0-3.1.
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 | /* karanari.h
*/
#ifndef _KARANARI_H
#define _KARANARI_H
#include "osl/rating/feature.h"
#include "osl/effect_util/neighboring8Direct.h"
#include "osl/neighboring8.h"
namespace osl
{
namespace rating
{
class Karanari : public Feature
{
bool bishop, can_promote_area;
public:
Karanari(bool b, bool c) : Feature(b ? "Bishop" : "Rook"), bishop(b), can_promote_area(c) {}
static bool matchGeneral(const NumEffectState& state, Move move)
{
if (! (move.isPromotion() && move.capturePtype() == PTYPE_EMPTY
&& move.from().canPromote(state.turn())))
return false;
const Square op_king = state.kingSquare(alt(state.turn()));
if (! Neighboring8Direct::hasEffect(state, move.oldPtypeO(), move.from(), op_king)
&& Neighboring8Direct::hasEffect(state, move.ptypeO(), move.to(), op_king))
return false;
return true;
}
bool match(const NumEffectState& state, Move move, const RatingEnv&) const
{
if (! (move.ptype() == (bishop ? PBISHOP : PROOK)
&& matchGeneral(state, move)))
return false;
if (can_promote_area)
return move.to().canPromote(move.player());
const Square my_king = state.kingSquare(state.turn());
if (bishop && Neighboring8::isNeighboring8(move.to(), my_king))
return false;
return true;
}
static int index(const NumEffectState& state, Move move)
{
int base;
switch (move.ptype()) {
case PBISHOP:
base = 2;
break;
case PROOK:
base = 0;
break;
default:
return -1;
}
if (! matchGeneral(state, move))
return -1;
if (move.to().canPromote(move.player()))
return base;
const Square my_king = state.kingSquare(state.turn());
if (/*bishop*/ base && Neighboring8::isNeighboring8(move.to(), my_king))
return -1;
return base + 1;
}
};
}
}
#endif /* _KARANARI_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|