Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

TwoDistance Class Reference

TwoDistance Evaluation Function. More...

#include <TwoDistance.hpp>

List of all members.

Public Types

enum  NeighbourType { ADJACENT, FULL_VC }

Two types of cell neighbourhoods: ADJACENT and FULL_VC.


Public Member Functions

 TwoDistance (NeighbourType ntype=ADJACENT)
 Compute the TwoDistance on the given HexBoard (with up-to-date VCs) and NeighbourType.
virtual ~TwoDistance ()
virtual void Evaluate (const HexBoard &brd)
 Computes the evaluation.
virtual HexEval Score () const
 Returns the computed score for BLACK, that is:
virtual HexEval Score (HexPoint cell) const
 Returns the sum of the BLACK and WHITE scores for this cell.
virtual HexEval Score (HexPoint cell, HexColor color) const
 Returns the score for cell and color.

Private Member Functions

void ComputeScores (HexColor color, HexEval *out)
void FindBest (HexEval *po, HexPoint &who, int &count)
void ComputeScore ()
void ComputeDistanceToEdge (HexColor color, HexPoint edge1, HexEval *out)
bool IsAdjacent (HexColor color, HexPoint p1, HexPoint p2)
void SetAllToInfinity (HexEval *out)

Private Attributes

const HexBoardm_brd
NeighbourType m_ntype
HexEval m_score

Detailed Description

TwoDistance Evaluation Function.

Computes the two distance from each cell to each of the four edges. The two distance is the second shortest distance between two cells (1 if they are adjacent, and infinity if fewer than two connecting paths exist).

This evaluation function requires that the VCs be precalculated for the given board state. This calcuation runs in O(n^2) time, where n is the number of cells on the board.

if NeighbourType is FULL_VC then the distance returned is not accurate since one cell we have a vc with could affect another cell we have a vc with.

Definition at line 32 of file TwoDistance.hpp.

Member Enumeration Documentation

Two types of cell neighbourhoods: ADJACENT and FULL_VC.

ADJACENT: standard adjacency, going through stones of like color. FULL_VC: two cells are adjacent if a FULL vc exists between them.


Definition at line 41 of file TwoDistance.hpp.

Constructor & Destructor Documentation

TwoDistance::TwoDistance ( NeighbourType  ntype = ADJACENT  )  [explicit]

Compute the TwoDistance on the given HexBoard (with up-to-date VCs) and NeighbourType.

Definition at line 15 of file TwoDistance.cpp.

TwoDistance::~TwoDistance (  )  [virtual]


Definition at line 22 of file TwoDistance.cpp.

Member Function Documentation

void TwoDistance::ComputeDistanceToEdge ( HexColor  color,
HexPoint  edge1,
HexEval out 
) [private]
void TwoDistance::ComputeScore (  )  [private]

Definition at line 74 of file TwoDistance.cpp.

References BLACK, FindBest(), m_score, m_scores, and WHITE.

Referenced by Evaluate().

void TwoDistance::ComputeScores ( HexColor  color,
HexEval out 
) [private]
void TwoDistance::Evaluate ( const HexBoard brd  )  [virtual]

Computes the evaluation.

Definition at line 28 of file TwoDistance.cpp.

References ComputeScore(), ComputeScores(), m_brd, and m_scores.

Referenced by BenzeneHtpEngine::CmdEvalTwoDist().

void TwoDistance::FindBest ( HexEval po,
HexPoint who,
int &  count 
) [private]
bool TwoDistance::IsAdjacent ( HexColor  color,
HexPoint  p1,
HexPoint  p2 
) [private]
HexEval TwoDistance::Score ( HexPoint  cell,
HexColor  color 
) const [inline, virtual]

Returns the score for cell and color.

This is the sum of the twodistances between both edges for cell.

Definition at line 102 of file TwoDistance.hpp.

References m_scores.

HexEval TwoDistance::Score ( HexPoint  cell  )  const [inline, virtual]

Returns the sum of the BLACK and WHITE scores for this cell.

Definition at line 108 of file TwoDistance.hpp.

References BLACK, m_scores, and WHITE.

HexEval TwoDistance::Score (  )  const [inline, virtual]

Returns the computed score for BLACK, that is:

Score = SCALE*(B_m - W_m) + (B_mc - W_mc);

Where SCALE is an arbitrary scaling factor (hex setting "twod-scale-factor"), B_m and W_m are the minimum BLACK and WHITE cell scores, and B_mc and W_mc are equal to the number of times B_m and W_m appear on the board.

B_mc and W_mc are tie breaking values. The intuition here is that a position with many cells with minimum potential is better than a position with only a single cell with minimum potential.

Definition at line 97 of file TwoDistance.hpp.

References m_score.

Referenced by BenzeneHtpEngine::CmdEvalTwoDist().

void TwoDistance::SetAllToInfinity ( HexEval out  )  [private]

Definition at line 160 of file TwoDistance.cpp.

References HexBoard::Const(), EVAL_INFINITY, ConstBoard::Interior(), and m_brd.

Referenced by ComputeDistanceToEdge().

Member Data Documentation

const HexBoard* TwoDistance::m_brd [private]

Definition at line 91 of file TwoDistance.hpp.

Referenced by IsAdjacent().

Definition at line 93 of file TwoDistance.hpp.

Referenced by ComputeScore(), and Score().

Definition at line 94 of file TwoDistance.hpp.

Referenced by ComputeScore(), Evaluate(), and Score().

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

6 Jan 2011 Doxygen 1.6.3