All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
boardBitMask.cc
Go to the documentation of this file.
2 #include "osl/ptype.h"
3 #include "osl/ptypeTable.h"
4 #include <iostream>
5 
6 namespace osl
7 {
8 namespace effect
9 {
10 
11  std::ostream& operator<<(std::ostream& os,BoardBitMask const& boardBitMask){
12  os << "[";
13  for(int i=15;i>=0;i--){
14  unsigned char uc=boardBitMask.bMask[i];
15  for(int j=7;j>=0;j--){
16  if((uc&(1<<j))!=0) os << "1";
17  else os<<"0";
18  }
19  os<<" ";
20  }
21  return os << "]";
22  }
23 
24 
26  for(int i=0;i<Square::SIZE;i++){
27  maskOfSquare[i].clearAll();
28  }
29  for(int y=1;y<=9;y++)
30  for(int x=1;x<=9;x++){
31  Square pos(x,y);
33  }
34  }
35 
36  static void setBetweenMask(BoardBitMask& mask,Square from,Square to,
37  Ptype ptype){
38  const EffectContent effect=Ptype_Table.getEffect(newPtypeO(BLACK,ptype),Offset32(to,from));
39  if(!effect.hasBlockableEffect()) return;
40  const Offset offset=effect.offset();
41  mask.clearAll();
42  for(Square pos=from+offset;pos!=to;pos+=offset){
43  mask.setBit(pos);
44  }
45  }
47  for(int j=0;j<Square::SIZE;j++){
48  for(int i=0;i<Square::SIZE;i++){
49  rookBetweenMask[i][j].setAll();
50  lanceBetweenMask[i][j].setAll();
51  bishopBetweenMask[i][j].setAll();
52  }
53  }
54  for(int y1=1;y1<=9;y1++)
55  for(int x1=1;x1<=9;x1++){
56  Square from(x1,y1);
57  for(int y2=1;y2<=9;y2++)
58  for(int x2=1;x2<=9;x2++){
59  Square to(x2,y2);
63  setBetweenMask(lanceBetweenMask[from.index()][to.index()],from,to,LANCE);
64  setBetweenMask(bishopBetweenMask[from.index()][to.index()],from,to,BISHOP);
65  setBetweenMask(rookBetweenMask[from.index()][to.index()],from,to,ROOK);
66  }
67  }
68  }
69 
73  }
74 } // namespace effect
75 } // namespace osl