#include <SgBoardConst.h>
All boards created with the same board size share the same data to reduce memory consumption and increase cache hits.
Definition at line 24 of file SgBoardConst.h.
Public Member Functions | |
SgBoardConst (SgGrid size) | |
void | ChangeSize (SgGrid newSize) |
Change the information for this object to another size. | |
SgGrid | Size () const |
Get board size. | |
SgGrid | Line (SgPoint p) const |
Distance from the nearest border point. | |
SgGrid | Pos (SgPoint p) const |
The distance to the second-closest border point. | |
int | Up (SgPoint p) const |
Offset for neighboring point away from edge of board. | |
int | Left (SgPoint p) const |
Offset for neighbor to the left, when looking in Up() direction. | |
int | Right (SgPoint p) const |
int | Side (SgPoint p, int i) const |
const SgPointSet & | Corners () const |
Set of points in corners of the board. | |
const SgPointSet & | Edges () const |
Set of points on edge but not in corners of the board. | |
const SgPointSet & | Centers () const |
All points on board not in Corners() or Edges(). | |
const SgPointSet & | SideExtensions () const |
Points for standard side extensions on lines 2 to 4. | |
const SgPointSet & | LineSet (SgGrid line) const |
Set of all points on given line. | |
int | FirstBoardPoint () const |
Upper left corner of the board. | |
int | LastBoardPoint () const |
See FirstBoardPoint. | |
const SgPoint * | NeighborIterAddress (SgPoint p) const |
List of on-board neighbor points terminated by SG_ENDPOINT. | |
const SgPoint * | BoardIterAddress () const |
const SgPoint * | BoardIterEnd () const |
const SgPoint * | LineIterAddress (SgGrid line) const |
const SgPoint * | CornerIterAddress () const |
Private Types | |
typedef SgArray< boost::shared_ptr< BoardConstImpl >, SG_MAX_SIZE+1 > | BoardConstImplArray |
Private Member Functions | |
void | Create (SgGrid size) |
Private Attributes | |
boost::shared_ptr< BoardConstImpl > | m_const |
Static Private Attributes | |
static BoardConstImplArray | s_const |
Classes | |
struct | BoardConstImpl |
typedef SgArray<boost::shared_ptr<BoardConstImpl>,SG_MAX_SIZE + 1> SgBoardConst::BoardConstImplArray [private] |
Definition at line 157 of file SgBoardConst.h.
SgBoardConst::SgBoardConst | ( | SgGrid | size | ) |
Definition at line 195 of file SgBoardConst.cpp.
References Create(), SG_ASSERT_GRIDRANGE, and SgInitCheck().
const SgPoint * SgBoardConst::BoardIterAddress | ( | ) | const |
const SgPoint * SgBoardConst::BoardIterEnd | ( | ) | const |
const SgPointSet & SgBoardConst::Centers | ( | ) | const |
All points on board not in Corners() or Edges().
Definition at line 216 of file SgBoardConst.h.
References m_const.
void SgBoardConst::ChangeSize | ( | SgGrid | newSize | ) |
Change the information for this object to another size.
Does nothing if 'newSize' is the same.
Definition at line 202 of file SgBoardConst.cpp.
References Create(), m_const, SG_ASSERT, and SG_ASSERT_GRIDRANGE.
const SgPoint * SgBoardConst::CornerIterAddress | ( | ) | const |
const SgPointSet & SgBoardConst::Corners | ( | ) | const |
Set of points in corners of the board.
On 12x12 boards and larger, this includes 5x5 area from corner except the 5,5 point itself (the classical opening moves and below). See SgBoardConst::BoardConstImpl::BoardConstImpl for details. On smaller boards, includes the 4x4 area except the 4,4 point itself.
Definition at line 206 of file SgBoardConst.h.
References m_const.
void SgBoardConst::Create | ( | SgGrid | size | ) | [private] |
Definition at line 185 of file SgBoardConst.cpp.
References m_const, s_const, SG_ASSERT, and SG_ASSERT_GRIDRANGE.
Referenced by ChangeSize(), and SgBoardConst().
const SgPointSet & SgBoardConst::Edges | ( | ) | const |
Set of points on edge but not in corners of the board.
On 12x12 boards and larger, this includes points on lines 1-4. On smaller boards, lines 1 to 3.
Definition at line 211 of file SgBoardConst.h.
References m_const.
int SgBoardConst::FirstBoardPoint | ( | ) | const |
Upper left corner of the board.
Using FirstBoardPoint and LastBoardPoint the board points can be traversed with a for-loop. This avoids the border points before and after the board, but not the ones to the side of the board; one must still check for border fields within the loop.
Definition at line 231 of file SgBoardConst.h.
References m_const.
int SgBoardConst::LastBoardPoint | ( | ) | const |
int SgBoardConst::Left | ( | SgPoint | p | ) | const |
Distance from the nearest border point.
Points on the edge of the board have distance 1; border (off-board) points have distance 0.
Definition at line 171 of file SgBoardConst.h.
References m_const.
const SgPointSet & SgBoardConst::LineSet | ( | SgGrid | line | ) | const |
List of on-board neighbor points terminated by SG_ENDPOINT.
Points are sorted from low to high.
Definition at line 176 of file SgBoardConst.h.
References m_const.
The distance to the second-closest border point.
Points on the edge of the board have distance 1; border (off-board) points have distance 0.
Definition at line 181 of file SgBoardConst.h.
References m_const.
int SgBoardConst::Right | ( | SgPoint | p | ) | const |
int SgBoardConst::Side | ( | SgPoint | p, | |
int | i | |||
) | const |
Definition at line 201 of file SgBoardConst.h.
References m_const, SG_NS, and SG_WE.
Referenced by SgSideIterator::operator *(), and SgSideIterator::SgSideIterator().
const SgPointSet & SgBoardConst::SideExtensions | ( | ) | const |
Points for standard side extensions on lines 2 to 4.
Definition at line 221 of file SgBoardConst.h.
References m_const.
SgGrid SgBoardConst::Size | ( | ) | const |
int SgBoardConst::Up | ( | SgPoint | p | ) | const |
Offset for neighboring point away from edge of board.
Definition at line 186 of file SgBoardConst.h.
References m_const.
boost::shared_ptr<BoardConstImpl> SgBoardConst::m_const [private] |
Definition at line 159 of file SgBoardConst.h.
Referenced by BoardIterAddress(), BoardIterEnd(), Centers(), ChangeSize(), CornerIterAddress(), Corners(), Create(), Edges(), FirstBoardPoint(), LastBoardPoint(), Left(), Line(), LineIterAddress(), LineSet(), NeighborIterAddress(), Pos(), Right(), Side(), SideExtensions(), Size(), and Up().
SgBoardConst::BoardConstImplArray SgBoardConst::s_const [static, private] |