My Project
boardMask.cc
Go to the documentation of this file.
1/* boardMask.cc
2 */
5#include <iostream>
6
7#ifndef MINIMAL
8std::ostream& osl::container::operator<<(std::ostream& os, const BoardMask& mask)
9{
10 for(int y=1; y<=9; ++y) {
11 for(int x=9; x>=1; --x) {
12 const Square p(x,y);
13 os << mask.test(p);
14 }
15 os << std::endl;
16 }
17 return os;
18}
19#endif
20
23{
24 for (int cx=1; cx<=9; ++cx) {
25 for (int cy=1; cy<=9; ++cy) {
26 const int min_x = std::max(1, cx - 2);
27 const int max_x = std::min(9, cx + 2);
28 const int min_y = std::max(1, cy - 2);
29 const int max_y = std::min(9, cy + 2);
30 BoardMask mask;
31 mask.clear();
32 for (int x=min_x; x<=max_x; ++x) {
33 for (int y=min_y; y<=max_y; ++y) {
34 mask.set(Square(x,y));
35 }
36 }
37 data[Square(cx,cy).index()] = mask;
38 }
39 }
40}
41
44{
45 for (int cx=1; cx<=9; ++cx) {
46 for (int cy=1; cy<=9; ++cy) {
47 const int min_x = std::max(1, cx - 1);
48 const int max_x = std::min(9, cx + 1);
49 const int min_y = std::max(1, cy - 1);
50 const int max_y = std::min(9, cy + 1);
51 BoardMask mask;
52 mask.clear();
53 for (int x=min_x; x<=max_x; ++x) {
54 for (int y=min_y; y<=max_y; ++y) {
55 mask.set(Square(x,y));
56 }
57 }
58 data[Square(cx,cy).index()] = mask;
59 }
60 }
61}
62
65{
66 for (int cx=1; cx<=9; ++cx) {
67 for (int cy=1; cy<=9; ++cy) {
68 const Square center = Centering5x3::adjustCenter(Square(cx, cy));
69 const int min_x = std::max(1, center.x() - 2);
70 const int max_x = std::min(9, center.x() + 2);
71 const int min_y = std::max(1, center.y() - 1);
72 const int max_y = std::min(9, center.y() + 1);
73 BoardMask mask;
74 mask.clear();
75 for (int x=min_x; x<=max_x; ++x) {
76 for (int y=min_y; y<=max_y; ++y) {
77 mask.set(Square(x,y));
78 }
79 }
80 data[Square(cx,cy).index()] = mask;
81 }
82 }
83}
84
85// ;;; Local Variables:
86// ;;; mode:c++
87// ;;; c-basic-offset:2
88// ;;; End:
unsigned int index() const
Definition basic_type.h:572
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
void set(unsigned int i)
Definition boardMask.h:40
bool test(unsigned int i) const
Definition boardMask.h:52
std::ostream & operator<<(std::ostream &, const BitXmask)
Definition bitXmask.cc:6