/usr/include/osl/eval/endgame/attackDefense.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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | /**
* attackDefense.h
*/
#ifndef EVAL_ENDGAME_ATTACKtDEFENSE_H
#define EVAL_ENDGAME_ATTACKtDEFENSE_H
#include "osl/eval/endgame/attackKing.h"
#include "osl/eval/endgame/defenseKing.h"
#include "osl/eval/pieceEval.h"
#include "osl/eval/evalTraits.h"
#include "osl/misc/carray.h"
namespace osl
{
namespace container
{
class PieceValues;
} // namespace container
namespace eval
{
namespace endgame
{
/**
* max(AttackKing, DefenseKing).
* うまく動くようなら統合した表を作る
*/
class AttackDefense
{
CArray<int,2> values;
void reset() { values.fill(0); }
void addValue(Player owner, int value)
{
values[playerToIndex(owner)] += value;
}
void addValue(Piece king_black, Piece king_white, Piece target)
{
assert(king_black.ptype() == KING);
assert(king_white.ptype() == KING);
assert(king_black.owner() == BLACK);
assert(king_white.owner() == WHITE);
addValue(target.owner(), valueOf(king_black, king_white, target));
}
public:
explicit AttackDefense(const SimpleState&);
void changeTurn() {}
static bool initialized() { return true; }
int value() const { return values[0] + values[1]; }
int value(Player p) const { return values[playerToIndex(p)]; }
void update(const SimpleState& new_state, Move last_move);
int expect(const SimpleState& state, Move move) const;
private:
void updateKingMove(const SimpleState&, Square from, Square to);
void updateKingMove(const SimpleState&, Square from, Square to,
Piece target);
public:
static int infty()
{
return PieceEval::infty()*2; // 2倍未満のボーナス
}
static int valueOf(Piece black_king, Piece white_king,
Piece target)
{
return valueOf(black_king, white_king,
target.ptypeO(), target.square());
}
static int valueOf(Piece black_king, Piece white_king,
PtypeO ptypeo, Square position)
{
assert(black_king.owner() == BLACK);
assert(white_king.owner() == WHITE);
const Player player = getOwner(ptypeo);
const Piece my_king
= (player == BLACK) ? black_king : white_king;
const Piece op_king
= (player == BLACK) ? white_king : black_king;
const int attack = AttackKing::valueOf(op_king, ptypeo, position);
const int defense = DefenseKing::valueOf(my_king, ptypeo, position);
return max(player, attack, defense);
}
static void setValues(const SimpleState&, container::PieceValues&);
static void resetWeights(const int *w);
};
} // namespace endgame
} // namespace endgame
} // namespace osl
#endif /* EVAL_ENDGAME_ATTACKKING_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|