ptypeProgress.cc
Go to the documentation of this file.
2 #include "osl/bits/pieceTable.h"
3 #include "osl/oslConfig.h"
4 #include <iostream>
5 
8  osl::progress::Ptype_Progress_Table.init();
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);
107  ret+=Ptype_Progress_Table.progress(p.ptypeO(),p.square());
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);
131  pos2Val[newPtypeO(BLACK,ptype)-PTYPEO_MIN][Square::STAND().index()]=ptype2Val[i]*yVals[5];
132  pos2Val[newPtypeO(WHITE,ptype)-PTYPEO_MIN][Square::STAND().index()]=ptype2Val[i]*yVals[5];
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
PtypeProgressTable Ptype_Progress_Table
Definition: ptypeProgress.cc:6
PtypeO newPtypeO(Player player, Ptype ptype)
Definition: basic_type.h:211
PieceMask & standMask(Player p)
Definition: simpleState.h:124
Ptype
駒の種類を4ビットでコード化する
Definition: basic_type.h:83
const Piece pieceOf(int num) const
Definition: simpleState.h:76
std::ostream & operator<<(std::ostream &os, LongEffect const &longEffect)
static const int SIZE
Definition: basic_type.h:794
static osl::SetUpRegister _initializer([](){ osl::progress::Ptype_Progress_Table.init();})
bool isOnBoard(int num) const
Definition: simpleState.h:176
const PieceTable Piece_Table
Definition: tables.cc:94
unsigned int index() const
Definition: basic_type.h:572
PtypeProgress(SimpleState const &state)
ゲームの進行度を駒が自陣からどの程度前に進んでいるかの和で表現
Definition: ptypeProgress.h:14
static const CArray< int, 10 > yVals
y 座標に対応した進行度の係数、最初は0 (使用しない)
Definition: ptypeProgress.h:19
int progress(PtypeO ptypeo, Square pos) const
Definition: ptypeProgress.h:23
Ptype getPtypeOf(int num) const
Definition: pieceTable.h:18
static const Square STAND()
Definition: basic_type.h:548
ゲームの進行度を測る駒の種類別の係数