boardMask.cc
Go to the documentation of this file.
/* boardMask.cc
*/
#include "osl/bits/boardMask.h"
#include "osl/bits/centering5x3.h"
#include <iostream>
#ifndef MINIMAL
std::ostream& osl::container::operator<<(std::ostream& os, const BoardMask& mask)
{
for(int y=1; y<=9; ++y) {
for(int x=9; x>=1; --x) {
const Square p(x,y);
os << mask.test(p);
}
os << std::endl;
}
return os;
}
#endif
osl::container::
BoardMaskTable5x5::BoardMaskTable5x5()
{
for (int cx=1; cx<=9; ++cx) {
for (int cy=1; cy<=9; ++cy) {
const int min_x = std::max(1, cx - 2);
const int max_x = std::min(9, cx + 2);
const int min_y = std::max(1, cy - 2);
const int max_y = std::min(9, cy + 2);
BoardMask mask;
mask.clear();
for (int x=min_x; x<=max_x; ++x) {
for (int y=min_y; y<=max_y; ++y) {
mask.set(Square(x,y));
}
}
data[Square(cx,cy).index()] = mask;
}
}
}
osl::container::
BoardMaskTable3x3::BoardMaskTable3x3()
{
for (int cx=1; cx<=9; ++cx) {
for (int cy=1; cy<=9; ++cy) {
const int min_x = std::max(1, cx - 1);
const int max_x = std::min(9, cx + 1);
const int min_y = std::max(1, cy - 1);
const int max_y = std::min(9, cy + 1);
BoardMask mask;
mask.clear();
for (int x=min_x; x<=max_x; ++x) {
for (int y=min_y; y<=max_y; ++y) {
mask.set(Square(x,y));
}
}
data[Square(cx,cy).index()] = mask;
}
}
}
osl::container::
BoardMaskTable5x3Center::BoardMaskTable5x3Center()
{
for (int cx=1; cx<=9; ++cx) {
for (int cy=1; cy<=9; ++cy) {
const Square center = Centering5x3::adjustCenter(Square(cx, cy));
const int min_x = std::max(1, center.x() - 2);
const int max_x = std::min(9, center.x() + 2);
const int min_y = std::max(1, center.y() - 1);
const int max_y = std::min(9, center.y() + 1);
BoardMask mask;
mask.clear();
for (int x=min_x; x<=max_x; ++x) {
for (int y=min_y; y<=max_y; ++y) {
mask.set(Square(x,y));
}
}
data[Square(cx,cy).index()] = mask;
}
}
}
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
boardMask.h
centering5x3.h
osl::Square
Definition basic_type.h:532
osl::Square::index
unsigned int index() const
Definition basic_type.h:572
osl::Square::y
int y() const
将棋としてのY座標を返す.
Definition basic_type.h:567
osl::Square::x
int x() const
将棋としてのX座標を返す.
Definition basic_type.h:563
osl::container::BoardMaskTable3x3::mask
const BoardMask & mask(Square p) const
p中心の3x3 の範囲のbitを立てたもの, centeringなし
Definition boardMask.h:123
osl::container::BoardMaskTable3x3::BoardMaskTable3x3
BoardMaskTable3x3()
Definition boardMask.cc:43
osl::container::BoardMaskTable3x3::data
CArray< BoardMask, Square::SIZE > data
Definition boardMask.h:119
osl::container::BoardMaskTable5x3Center::mask
const BoardMask & mask(Square p) const
p中心の5x3 の範囲のbitを立てたもの, centering
Definition boardMask.h:133
osl::container::BoardMaskTable5x3Center::data
CArray< BoardMask, Square::SIZE > data
Definition boardMask.h:129
osl::container::BoardMaskTable5x3Center::BoardMaskTable5x3Center
BoardMaskTable5x3Center()
Definition boardMask.cc:64
osl::container::BoardMaskTable5x5::mask
const BoardMask & mask(Square p) const
p中心の5x5 の範囲のbitを立てたもの, centeringなし
Definition boardMask.h:113
osl::container::BoardMaskTable5x5::data
CArray< BoardMask, Square::SIZE > data
Definition boardMask.h:109
osl::container::BoardMaskTable5x5::BoardMaskTable5x5
BoardMaskTable5x5()
Definition boardMask.cc:22
osl::container::BoardMask
11 x 12
Definition boardMask.h:21
osl::container::BoardMask::test
bool test(unsigned int i) const
Definition boardMask.h:52
osl::container::operator<<
std::ostream & operator<<(std::ostream &, const BitXmask)
Definition bitXmask.cc:6
osl::Centering5x3::adjustCenter
static const Square adjustCenter(Square src)
Definition centering5x3.h:23