Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgBoardConst Class Reference

#include <SgBoardConst.h>

List of all members.


Detailed Description

Constant data for a given board size for games with square boards.

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 SgPointSetCorners () const
 Set of points in corners of the board.
const SgPointSetEdges () const
 Set of points on edge but not in corners of the board.
const SgPointSetCenters () const
 All points on board not in Corners() or Edges().
const SgPointSetSideExtensions () const
 Points for standard side extensions on lines 2 to 4.
const SgPointSetLineSet (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 SgPointNeighborIterAddress (SgPoint p) const
 List of on-board neighbor points terminated by SG_ENDPOINT.
const SgPointBoardIterAddress () const
const SgPointBoardIterEnd () const
const SgPointLineIterAddress (SgGrid line) const
const SgPointCornerIterAddress () 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< BoardConstImplm_const

Static Private Attributes

static BoardConstImplArray s_const

Classes

struct  BoardConstImpl


Member Typedef Documentation

typedef SgArray<boost::shared_ptr<BoardConstImpl>,SG_MAX_SIZE + 1> SgBoardConst::BoardConstImplArray [private]

Definition at line 157 of file SgBoardConst.h.


Constructor & Destructor Documentation

SgBoardConst::SgBoardConst ( SgGrid  size  ) 

Definition at line 195 of file SgBoardConst.cpp.

References Create(), SG_ASSERT_GRIDRANGE, and SgInitCheck().


Member Function Documentation

const SgPoint * SgBoardConst::BoardIterAddress (  )  const

Definition at line 241 of file SgBoardConst.h.

References m_const.

const SgPoint * SgBoardConst::BoardIterEnd (  )  const

Definition at line 246 of file SgBoardConst.h.

References m_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

Definition at line 256 of file SgBoardConst.h.

References m_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

See FirstBoardPoint.

Definition at line 236 of file SgBoardConst.h.

References m_const.

int SgBoardConst::Left ( SgPoint  p  )  const

Offset for neighbor to the left, when looking in Up() direction.

Definition at line 191 of file SgBoardConst.h.

References m_const, SG_NS, and SG_WE.

SgGrid SgBoardConst::Line ( 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 SgPoint * SgBoardConst::LineIterAddress ( SgGrid  line  )  const

Definition at line 251 of file SgBoardConst.h.

References m_const.

const SgPointSet & SgBoardConst::LineSet ( SgGrid  line  )  const

Set of all points on given line.

Definition at line 226 of file SgBoardConst.h.

References m_const.

const SgPoint * SgBoardConst::NeighborIterAddress ( SgPoint  p  )  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.

SgGrid SgBoardConst::Pos ( SgPoint  p  )  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

Definition at line 196 of file SgBoardConst.h.

References m_const, SG_NS, and SG_WE.

int SgBoardConst::Side ( SgPoint  p,
int  i 
) const

Todo:

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

Get board size.

Definition at line 166 of file SgBoardConst.h.

References m_const.

int SgBoardConst::Up ( SgPoint  p  )  const

Offset for neighboring point away from edge of board.

Todo:
: the following seems weird, remove? Can also be a diagonal neighbor if no direct up-neighbor exists. If no up-neighbor exists at all, returns offset of 0.

Definition at line 186 of file SgBoardConst.h.

References m_const.


Member Data Documentation

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]

Definition at line 163 of file SgBoardConst.h.

Referenced by Create().


The documentation for this class was generated from the following files:


17 Jun 2010 Doxygen 1.4.7