All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
effectedNumTable.cc
Go to the documentation of this file.
1 /* effectedNumTable.cc
2  */
4 #include "osl/ptypeTable.h"
5 #include "osl/boardTable.h"
6 
7 void
9 {
10  for(int i=0;i<40;i++) contents[i].clear();
11 }
12 
14 {
15  clear();
16  for(int num=32;num<=39;num++){
17  osl::Piece p=state.pieceOf(num);
18  if(!p.isOnBoard()) continue;
19  int moveMask=Ptype_Table.getMoveMask(p.ptype());
20  for(int i=0;i<8;i++){
21  Direction d=static_cast<Direction>(i);
22  if(p.owner()==WHITE) d=inverse(d);
23  Direction longD=shortToLong(d);
24  if((moveMask&dirToMask(longD))==0) continue;
25  Offset o=Board_Table.getOffsetForBlack(static_cast<Direction>(i));
26  Square pos=p.square()+o;
27  Piece p1;
28  for(;(p1=state.pieceAt(pos)).isEmpty();pos+=o) ;
29  if(pos.isEdge()) continue;
30  int num1=p1.number();
31  contents[num1][static_cast<Direction>(i)]=num1;
32  }
33  }
34 }
35 
36 std::ostream& osl::effect::operator<<(std::ostream& os,osl::EffectedNumTable const& et)
37 {
38  os << "[\n";
39  for(int num=0;num<=39;num++){
40  os << " [";
41  for(int d=0;d<7;d++) os << et[num][static_cast<Direction>(d)] << ",";
42  os << et[num][static_cast<Direction>(7)] << "],\n";
43  }
44  return os << "]\n";
45 }
47 {
48  for(int i=0;i<8;i++){
49  for(int num=0;num<=39;num++){
50  if(e1[num][static_cast<Direction>(i)]!=e2[num][static_cast<Direction>(i)]) return false;
51  }
52  }
53  return true;
54 }