This file is indexed.

/usr/include/osl/eval/ppair/piecePairEval.h is in libosl-dev 0.6.0-3.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
 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
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/* piecePairEval.h
 */
#ifndef _PIECE_PAIR_EVAL_H
#define _PIECE_PAIR_EVAL_H

#include "osl/eval/ppair/piecePairIndex.h"
#include "osl/eval/pieceEval.h"
#include "osl/eval/evalTraits.h"
#include "osl/state/simpleState.h"
#include "osl/move.h"
#include "osl/misc/carray.h"
#include <iosfwd>

namespace osl
{
  namespace container
  {
    class PieceValues;
  } // container
  
  namespace eval
  {
    namespace ppair
    {
      /**
       * PiecePairEval の,template parameterに依存しない部分の
       * 共通の実装.
       */
      class PiecePairEvalBase
      {
      protected:
	int val;
	PiecePairEvalBase() : val(0)
	{
	}
	~PiecePairEvalBase()
	{
	}
      public:
	/** roundup は 2^n であること */
	static const int ROUND_UP = 2;
	static int roundUp(int v)
	{
	  return v & (~(ROUND_UP-1)); 
	}
	int value() const	{ return roundUp(val); }
	int rawValue() const { return val; }
	static int infty()
	{
	  // ProgressEval で足してもoverflowしない値にする
	  // PieceEval::infty() + 100*40*39/2
	  return 150000;
	}

	static int captureValue(PtypeO ptypeo)
	{
	  return PieceEval::captureValue(ptypeo); 
	}
      };

      template <class Table>
      class PiecePairEvalTableBase : public PiecePairEvalBase
      {
      protected:
	// 必ず継承して使う
	explicit PiecePairEvalTableBase(const SimpleState& state);
	~PiecePairEvalTableBase() {}
      public:
	/**
	 * 駒が old_index から new_index に動いたときの値の差分
	 * @param state 動く前の局面
	 * @param old_index 駒+移動元
	 * @param new_index 駒+移動先
	 */
	static int adjustPairs(const SimpleState& state,
			       unsigned int new_index);    
	static int adjustPairs(const SimpleState& state,
			       unsigned int old_index, unsigned int new_index);    
	static int adjustPairs(const SimpleState& state, 
			       unsigned int old_index, unsigned int old_index2, 
			       unsigned int new_index);
	static int diffAfterSimpleMove(const SimpleState& state,
				       Square from, Square to, 
				       int promote_mask)
	{
	  const Piece old_piece=state.pieceAt(from);
	  const PtypeO newPtypeO = promoteWithMask(old_piece.ptypeO(), promote_mask);
	  const unsigned int old_index = PiecePairIndex::indexOf(old_piece);
	  const unsigned int new_index = PiecePairIndex::indexOf(to, newPtypeO);
	  return adjustPairs(state, old_index, new_index);
	}
	static int diffAfterDropMove(const SimpleState& state,Square to,PtypeO ptypeo)
	{
	  const unsigned int new_index = PiecePairIndex::indexOf(to, ptypeo);
	  return adjustPairs(state, new_index);
	}
	static int diffAfterCaptureMove(const SimpleState& state,
					Square from, Square to, 
					PtypeO victim,int promote_mask)
	{
	  const Piece old_piece=state.pieceAt(from);
	  const PtypeO newPtypeO = promoteWithMask(old_piece.ptypeO(), promote_mask);
	  const unsigned int old_index = PiecePairIndex::indexOf(old_piece);
	  const unsigned int new_index = PiecePairIndex::indexOf(to, newPtypeO);

	  const unsigned int indexVictim = PiecePairIndex::indexOf(to, victim);
	  return adjustPairs(state, old_index, indexVictim, 
			     new_index);
	}
	/** この時 state は move した後
	 */
	static int adjustPairsAfterMove(const SimpleState& state,
					unsigned int new_index);    
	static int adjustPairsAfterMove(const SimpleState& state,
					unsigned int old_index, unsigned int new_index);    
	static int adjustPairsAfterMove(const SimpleState& state, 
					unsigned int old_index, unsigned int old_index2, 
					unsigned int new_index);
	static int diffWithUpdate(const SimpleState& new_state, Move last_move)
	{
	  const unsigned int new_index = PiecePairIndex::indexOf(last_move.to(), last_move.ptypeO());
	  if (last_move.isDrop())
	    return adjustPairsAfterMove(new_state, new_index);
	  
	  const unsigned int old_index = PiecePairIndex::indexOf(last_move.from(), last_move.oldPtypeO());
	  if (last_move.capturePtype() == PTYPE_EMPTY)
	    return adjustPairsAfterMove(new_state, old_index, new_index);

	  const unsigned int index_victim = PiecePairIndex::indexOf(last_move.to(), last_move.capturePtypeO());
	  return adjustPairsAfterMove(new_state, old_index, index_victim, new_index);
	}
	/**
	 * 関係の値をPiece 毎の価値に変換する.
	 * - 駒Aの価値は r(A,A) + \sum_B(r(A+B)/2)
	 * - 但し,A,Bのどちらか(のみ)玉の時には,玉でない方に関係の点数を集める
	 */
	static void setValues(const SimpleState&, container::PieceValues&);

      private:
	static bool& initializationFlag();
      public:
	static bool initialized() { return initializationFlag(); } // read only
	static bool setUp(const char *filename);
	static bool setUp();
      };

      /**
       * 駒のペアの統計情報を元にした評価関数の共通部分.
       * - 必ず偶数
       * - 先手有利 +, 後手有利 -
       * @param Table PiecePairTable のどれかのinstatiationを想定
       */
      template <class Eval,class Table>
      class PiecePairEval : public PiecePairEvalTableBase<Table>
      {
      protected:
	// 必ず継承して使う
	explicit PiecePairEval(const SimpleState& state);
      public:
	typedef PiecePairEvalTableBase<Table> base_t;
	void changeTurn() {}
	/** この時 state は move する前
	 */
	int expect(const SimpleState& state, Move m) const;
	/** この時 state は move した後
	 */
	void update(const SimpleState& new_state, Move last_move)
	{
	  base_t::val += Eval::diffWithUpdate(new_state, last_move);
	}
	  
	static int diffWithMove(const SimpleState& state, Move move)
	{
	  // TRICK: Eval::diffXXX とすることでsubclassによるoverrideを可能にする
	  const Square from=move.from();
	  const Square to=move.to();
	  if (from.isPieceStand())
	    return Eval::diffAfterDropMove(state, to, move.ptypeO());

	  const Ptype ptypeCaptured=move.capturePtype();
	  if (ptypeCaptured != PTYPE_EMPTY)
	    return Eval::diffAfterCaptureMove(state, from, to,
					      newPtypeO(alt(move.player()),
							ptypeCaptured),
					      move.promoteMask());

	  return Eval::diffAfterSimpleMove(state, from,to,move.promoteMask());
	}
	
      };

    } // namespace ppair
  } // namespace eval
} // namespace osl

#endif /* _PIECE_PAIR_EVAL_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End: