All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ptypeProgress.cc
Go to the documentation of this file.
2 #include "osl/pieceTable.h"
3 #include <iostream>
4 
5 namespace osl
6 {
7  namespace progress
8  {
10  template<Ptype T>
12  // 歩
13  template<>
15  static const int val=2;
16  };
17  template<>
19  static const int val=2;
20  };
21  //
22  template<>
24  static const int val=5;
25  };
26  template<>
28  static const int val=5;
29  };
30  //
31  template<>
33  static const int val=5;
34  };
35  template<>
37  static const int val=5;
38  };
39  //
40  template<>
42  static const int val=7;
43  };
44  template<>
46  static const int val=7;
47  };
48  //
49  template<>
51  static const int val=8;
52  };
53  //
54  template<>
56  static const int val=7;
57  };
58  template<>
60  static const int val=7;
61  };
62  //
63  template<>
65  static const int val=10;
66  };
67  template<>
69  static const int val=10;
70  };
71  //
72  template<>
74  static const int val=15;
75  };
76  } // namespace progress
77 } // namespace osl
78 
80 PtypeProgress::PtypeProgress(SimpleState const& state)
81 {
82  int ret=0;
83  for (int num=0; num<Piece::SIZE; num++)
84  {
85  if(state.standMask(BLACK).test(num)){
87  Square::STAND());
88  }
89  else if(state.standMask(WHITE).test(num)){
91  Square::STAND());
92  }
93  else{
94  assert(state.isOnBoard(num));
95  const Piece p=state.pieceOf(num);
96  ret+=Ptype_Progress_Table.progress(p.ptypeO(),p.square());
97  }
98  }
99  val=ret;
100 }
101 
103 {
118  for(int i=PTYPE_MIN;i<=PTYPE_MAX;i++){
119  Ptype ptype=static_cast<Ptype>(i);
121  pos2Val[newPtypeO(WHITE,ptype)-PTYPEO_MIN][Square::STAND().index()]=ptype2Val[i]*yVals[5];
122  for(int y=1;y<10;y++)
123  {
124  for(int x=9;x>0;x--)
125  {
126  pos2Val[newPtypeO(BLACK,ptype)-PTYPEO_MIN][Square(x,y).index()]
127  = ptype2Val[i]*yVals[y];
128  pos2Val[newPtypeO(WHITE,ptype)-PTYPEO_MIN][Square(x,10-y).index()]
129  = ptype2Val[i]*yVals[y];
130  }
131  }
132  }
133 }
134 
136 }
137 
138 #ifndef MINIMAL
139 std::ostream& osl::progress::operator<<(std::ostream& os, PtypeProgress prog)
140 {
141  return os << "progress " << prog.progress();
142 }
143 #endif
144 // ;;; Local Variables:
145 // ;;; mode:c++
146 // ;;; c-basic-offset:2
147 // ;;; coding:utf-8
148 // ;;; End: