This file is indexed.

/usr/include/osl/state/simpleState.h is in libosl-dev 0.4.2-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
 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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/* simpleState.h
 */
#ifndef OSL_SIMPLE_STATE_H
#define OSL_SIMPLE_STATE_H

#include "osl/misc/loki.h"
#include "osl/direction.h"
#include "osl/boardTable.h"
#include "osl/ptype.h"
#include "osl/ptypeTraits.h"
#include "osl/piece.h"
#include "osl/container/pieceMask.h"
#include "osl/container/bitXmask.h"
#include "osl/effectContent.h"
#include "osl/move.h"
#include "osl/player.h"
#include "osl/handicap.h"
#include "osl/misc/carray.h"
#include "osl/effect_action/pieceFilter.h"
#include "osl/ptypeTable.h"

#include <iosfwd>

namespace osl
{
  namespace state
  {
    class SimpleState;
    std::ostream& operator<<(std::ostream& os,const SimpleState& state);
    /**
     * 盤上の駒のみを比較する(持ち駒は見ない).
     * なお、駒番に非依存な局面比較をしたい場合は、osl::record::CompactBoardや
     * osl::hash::HashKeyを用いる.
     */
    bool operator==(const SimpleState& st1,const SimpleState& st2);

    class SimpleState
    {
    private:
      friend std::ostream& operator<<(std::ostream& os,const SimpleState& state);
      friend bool operator==(const SimpleState& st1,const SimpleState& st2);
      typedef SimpleState state_t;
    public:
      static const bool hasPawnMask=true;
    protected:
      CArray<Piece,Square::SIZE> board
#ifdef __GNUC__
      __attribute__((aligned(16)))
#endif
	;
      /**
       * 全てのpieceが登録されている
       */
      CArray<Piece,Piece::SIZE> pieces
#ifdef __GNUC__
      __attribute__((aligned(16)))
#endif
	;
      CArray<PieceMask,2> stand_mask;
      CArray<BitXmask,2> pawnMask;
      CArray<CArray<char,PTYPE_SIZE-PTYPE_BASIC_MIN>,2> stand_count;

      /** 手番 */
      Player player_to_move;
      PieceMask used_mask;
    public:
      // 生成に関するもの
      explicit SimpleState();
      explicit SimpleState(Handicap h);
      // public継承させるには,virtual destructorを定義する.
      virtual ~SimpleState();
      /** 盤面が空の状態に初期化 */
      void init();
      /** ハンディに応じた初期状態に初期化 */
      void init(Handicap h);
      // private:
      void initPawnMask();
    public:
      const Piece pieceOf(int num) const{
	return pieces[num];
      }
      void setPieceOf(int num,Piece p) {
	pieces[num]=p;
      }
      template<Player P>
      const Piece kingPiece() const{
	return pieceOf(KingTraits<P>::index);
      }
      const Piece kingPiece(Player P) const{
	assert(isValid(P));
	if (P==BLACK)
	  return kingPiece<BLACK>();
	else
	  return kingPiece<WHITE>();
      }
      template<Player P>
      Square kingSquare() const{
	return kingPiece<P>().square();
      }
      Square kingSquare(Player player) const{
	assert(isValid(player));
	if (player==BLACK)
	  return kingSquare<BLACK>();
	else
	  return kingSquare<WHITE>();
      }
      template <Ptype PTYPE>
      static int nthLimit() {
	return PtypeTraits<PTYPE>::indexLimit - PtypeTraits<PTYPE>::indexMin;
      }
      /**
       * unpromote(PTYPE)のn番目の駒を帰す.  
       * 
       * 駒番号に依存するので順番は不定.
       */
      template <Ptype PTYPE>
      const Piece nth(int n) const {
	assert(0 <= n && n < nthLimit<PTYPE>());
	return pieceOf(PtypeTraits<PTYPE>::indexMin+n);
      }

      void setBoard(Square sq,Piece piece)
      {
	board[sq.index()]=piece;
      }
    protected:
      PieceMask& standMask(Player p) {
	return stand_mask[p];
      }
    public:
      const PieceMask& standMask(Player p) const {
	return stand_mask[p];
      }
      const PieceMask& usedMask() const {return used_mask;}
      bool isOffBoard(int num) const{
	return standMask(BLACK).test(num) 
	  || standMask(WHITE).test(num);
      }
      // protected:
      /** (internal) */
      void clearPawn(Player pl,Square sq){
	pawnMask[pl].clear(sq);
      }
      /** (internal) */
      void setPawn(Player pl,Square sq){
	pawnMask[pl].set(sq);
      }
    public:      
      bool isPawnMaskSet(Player player, int x) const
      {
	return pawnMask[player].isSet(x);
      }

      template<Player P>
      bool isPawnMaskSet(int x)const {return isPawnMaskSet(P,x); }

      /** xの筋に歩を打てる */
      bool canDropPawnTo(Player player, int x) const
      {
	return hasPieceOnStand<PAWN>(player) && ! isPawnMaskSet(player, x);
      }

      void setPiece(Player player,Square sq,Ptype ptype);
      void setPieceAll(Player player);

      /**
       * @param sq は isOnboardを満たす Square の12近傍(8近傍+桂馬の利き)
       * ! isOnBoard(sq) の場合は PIECE_EDGE を返す
       */
      const Piece pieceAt(Square sq) const { return board[sq.index()];}
      const Piece operator[](Square sq) const { return pieceAt(sq);}
      const Piece* getPiecePtr(Square sq) const { return &board[sq.index()];}
      const Piece pieceOnBoard(Square sq) const
      {
	assert(sq.isOnBoard());
	return pieceAt(sq);
      }

      bool isOnBoard(int num) const {
	return pieceOf(num).isOnBoard();
      }
      /**
       * 持駒の枚数を数える
       */
      int countPiecesOnStand(Player pl,Ptype ptype) const {
	assert(isBasic(ptype));
	return stand_count[pl][ptype-PTYPE_BASIC_MIN];
      }
      /** 後方互換 */
      template <Ptype Type>
      int countPiecesOnStand(Player pl) const {
	return countPiecesOnStand(pl, Type);
      }
      bool hasPieceOnStand(Player player,Ptype ptype) const{
	return countPiecesOnStand(player, ptype)!=0;
      }
      template<Ptype T>
      bool hasPieceOnStand(Player P) const {
	return countPiecesOnStand(P, T);
      }
    private:
      int countPiecesOnStandBit(Player pl,Ptype ptype) const {
	return (standMask(pl).getMask(Ptype_Table.getIndex(ptype))
		& Ptype_Table.getMaskLow(ptype)).countBit();
      }
    public:
      /**
       * diff方向にあるPiece を求める. 
       * @return 盤外ならPTYPE_EDGE
       */
      Piece nextPiece(Square cur, Offset diff) const
      {
	assert(! diff.zero());
	cur += diff;
	while (pieceAt(cur) == Piece::EMPTY())
	  cur += diff;
	return pieceAt(cur);
      }
    
      void setTurn(Player player) {
	player_to_move=player;
      }
      Player turn() const{
	return player_to_move;
      }
      /**
       * 手番を変更する
       */
      void changeTurn() {
	player_to_move = alt(player_to_move);
      }
      // check
      bool isConsistent(bool show_error=true) const;
      /** エラー表示をするかどうかをtemplateパラメータにした高速化版 */
      template <bool show_error>
      bool isAlmostValidMove(Move move) const;
      /**
       * 合法手かどうかを簡単に検査する.局面に依存するチェックのみ.
       * ルール上指せない手である可能性がある場合は,isValidMove を用いる.
       *
       * 局面に依存する検査でも,玉の素抜きや王手を防いでいるか,
       * 千日手,打歩詰かどうかは検査しない.
       */
      bool isAlmostValidMove(Move move,bool show_error=true) const;
      /**
       * 合法手かどうかを検査する.
       * isValidMoveByRule, isAlmostValidMove をおこなう.
       * 玉の素抜きや王手を防いでいるか,
       * 千日手,打歩詰かどうかは検査しない.
       */
      bool isValidMove(Move move,bool show_error=true) const;
    protected:
      template <bool show_error> bool isAlmostValidDrop(Move move) const;
      template <bool show_error> bool testValidityOtherThanEffect(Move move) const;
    public:
      /**
       * 盤面以外の部分の反則のチェック
       *
       */
      static bool isValidMoveByRule(Move move,bool show_error);

      /**
       * @param from - マスの位置
       * @param to - マスの位置
       * @param offset - fromからtoへのshort offset
       * fromとtoがクイーンで利きがある位置関係にあるという前提
       * で,間が全部空白かをチェック
       * @param pieceExistsAtTo - toに必ず駒がある (toが空白でも動く)
       */
      bool isEmptyBetween(Square from, Square to,Offset offset,bool pieceExistsAtTo=false) const
#ifdef __GNUC__
	__attribute__ ((pure))
#endif
      {
	assert(from.isOnBoard());
	assert(! offset.zero());
	assert(offset==Board_Table.getShortOffset(Offset32(to,from)));
	Square sq=from+offset;
	for (; pieceAt(sq).isEmpty(); sq+=offset) {
	  if (!pieceExistsAtTo && sq==to) 
	    return true;
	}
	return sq==to;
      
      }
      /**
       * @param from - マスの位置
       * @param to - マスの位置
       * fromとtoがクイーンで利きがある位置関係にあるという前提
       * で,間が全部空白かをチェック
       */
      bool
#ifdef __GNUC__
	__attribute__ ((pure))
#endif
      isEmptyBetween(Square from, Square to,bool noSpaceAtTo=false) const{
	assert(from.isOnBoard());
	Offset offset=Board_Table.getShortOffset(Offset32(to,from));
	assert(! offset.zero());
	return isEmptyBetween(from,to,offset,noSpaceAtTo);
      }

      /** dump: 自分を cerr に表示する。abort 前などにデバッグに使う */
      bool dump() const;
      /**
       * from で表現されたPieceをnew_ownerの持駒にした局面を作る.
       */
      const SimpleState emulateCapture(Piece from, Player new_owner) const;

      /**
       * from からto に ptypeの持駒を一枚渡した局面を作る.
       */
      const SimpleState emulateHandPiece(Player from, Player to, Ptype ptype) const;
      const SimpleState rotate180() const;
      const SimpleState flipHorizontal() const;
    };  
  } // namespace state
  using state::SimpleState;

} // namespace osl

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