My Project
ptypeProgress.cc
Go to the documentation of this file.
2 #include "osl/bits/pieceTable.h"
3 #include "osl/oslConfig.h"
4 #include <iostream>
5 
9 });
12 {{
13  0,4,4,4,3,2,1,0,0,0
14 }};
15 
16 namespace osl
17 {
18  namespace progress
19  {
21  template<Ptype T>
23  // 歩
24  template<>
26  static const int val=2;
27  };
28  template<>
30  static const int val=2;
31  };
32  //
33  template<>
35  static const int val=5;
36  };
37  template<>
39  static const int val=5;
40  };
41  //
42  template<>
44  static const int val=5;
45  };
46  template<>
48  static const int val=5;
49  };
50  //
51  template<>
53  static const int val=7;
54  };
55  template<>
57  static const int val=7;
58  };
59  //
60  template<>
62  static const int val=8;
63  };
64  //
65  template<>
67  static const int val=7;
68  };
69  template<>
71  static const int val=7;
72  };
73  //
74  template<>
76  static const int val=10;
77  };
78  template<>
80  static const int val=10;
81  };
82  //
83  template<>
85  static const int val=15;
86  };
87  } // namespace progress
88 } // namespace osl
89 
92 {
93  int ret=0;
94  for (int num=0; num<Piece::SIZE; num++)
95  {
96  if(state.standMask(BLACK).test(num)){
98  Square::STAND());
99  }
100  else if(state.standMask(WHITE).test(num)){
102  Square::STAND());
103  }
104  else{
105  assert(state.isOnBoard(num));
106  const Piece p=state.pieceOf(num);
108  }
109  }
110  val=ret;
111 }
112 
114 {
129  for(int i=PTYPE_MIN;i<=PTYPE_MAX;i++){
130  Ptype ptype=static_cast<Ptype>(i);
133  for(int y=1;y<10;y++)
134  {
135  for(int x=9;x>0;x--)
136  {
137  pos2Val[newPtypeO(BLACK,ptype)-PTYPEO_MIN][Square(x,y).index()]
138  = ptype2Val[i]*yVals[y];
139  pos2Val[newPtypeO(WHITE,ptype)-PTYPEO_MIN][Square(x,10-y).index()]
140  = ptype2Val[i]*yVals[y];
141  }
142  }
143  }
144 }
145 
147 }
148 
149 #ifndef MINIMAL
150 std::ostream& osl::progress::operator<<(std::ostream& os, PtypeProgress prog)
151 {
152  return os << "progress " << prog.progress();
153 }
154 #endif
155 // ;;; Local Variables:
156 // ;;; mode:c++
157 // ;;; c-basic-offset:2
158 // ;;; coding:utf-8
159 // ;;; End:
bool test(int num) const
Definition: pieceMask.h:45
Ptype getPtypeOf(int num) const
Definition: pieceTable.h:18
PtypeO ptypeO() const
Definition: basic_type.h:824
const Square square() const
Definition: basic_type.h:832
bool isOnBoard(int num) const
Definition: simpleState.h:176
PieceMask & standMask(Player p)
Definition: simpleState.h:124
const Piece pieceOf(int num) const
Definition: simpleState.h:76
unsigned int index() const
Definition: basic_type.h:572
static const Square STAND()
Definition: basic_type.h:548
ゲームの進行度を駒が自陣からどの程度前に進んでいるかの和で表現
Definition: ptypeProgress.h:15
static const CArray< int, 10 > yVals
y 座標に対応した進行度の係数、最初は0 (使用しない)
Definition: ptypeProgress.h:19
int progress(PtypeO ptypeo, Square pos) const
Definition: ptypeProgress.h:23
CArray2d< int, PTYPEO_SIZE, Square::SIZE > pos2Val
Definition: ptypeProgress.h:18
CArray< int, PTYPE_SIZE > ptype2Val
Definition: ptypeProgress.h:17
PtypeProgress(SimpleState const &state)
std::ostream & operator<<(std::ostream &os, LongEffect const &longEffect)
PtypeProgressTable Ptype_Progress_Table
Definition: ptypeProgress.cc:6
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:84
@ PTYPE_MAX
Definition: basic_type.h:105
@ ROOK
Definition: basic_type.h:100
@ PPAWN
Definition: basic_type.h:87
@ BISHOP
Definition: basic_type.h:99
@ PROOK
Definition: basic_type.h:92
@ PAWN
Definition: basic_type.h:95
@ KING
Definition: basic_type.h:93
@ KNIGHT
Definition: basic_type.h:97
@ SILVER
Definition: basic_type.h:98
@ PKNIGHT
Definition: basic_type.h:89
@ GOLD
Definition: basic_type.h:94
@ PLANCE
Definition: basic_type.h:88
@ PBISHOP
Definition: basic_type.h:91
@ LANCE
Definition: basic_type.h:96
@ PTYPE_MIN
Definition: basic_type.h:102
@ PSILVER
Definition: basic_type.h:90
const PieceTable Piece_Table
Definition: tables.cc:94
@ WHITE
Definition: basic_type.h:10
@ BLACK
Definition: basic_type.h:9
@ PTYPEO_MIN
Definition: basic_type.h:200
PtypeO newPtypeO(Player player, Ptype ptype)
Definition: basic_type.h:211
static osl::SetUpRegister _initializer([](){ osl::progress::Ptype_Progress_Table.init();})
ゲームの進行度を測る駒の種類別の係数