TwoDistance Evaluation Function. More...

`#include <TwoDistance.hpp>`

## Public Types | |

enum | NeighbourType { ADJACENT, FULL_VC } |

Two types of cell neighbourhoods: ADJACENT and FULL_VC. More... | |

## Public Member Functions | |

TwoDistance (NeighbourType ntype=ADJACENT) | |

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

virtual | ~TwoDistance () |

Destructor. | |

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 HexBoard * | m_brd |

NeighbourType | m_ntype |

HexEval | m_score |

HexEval | m_scores [BLACK_AND_WHITE][BITSETSIZE] |

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.

**Bug:**- 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.

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.

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]` |

Destructor.

Definition at line 22 of file TwoDistance.cpp.

Definition at line 100 of file TwoDistance.cpp.

References StoneBoard::GetEmpty(), HexBoard::GetPosition(), IsAdjacent(), m_brd, and SetAllToInfinity().

Referenced by ComputeScores().

void TwoDistance::ComputeScore | ( | ) | ` [private]` |

Definition at line 74 of file TwoDistance.cpp.

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

Referenced by Evaluate().

Definition at line 36 of file TwoDistance.cpp.

References TwoDistUtil::AddDistance(), BITSETSIZE, HexPointUtil::colorEdge1(), HexPointUtil::colorEdge2(), ComputeDistanceToEdge(), HexBoard::Const(), HexBoard::GetPosition(), HexEval, ConstBoard::Interior(), StoneBoard::IsOccupied(), and m_brd.

Referenced by Evaluate().

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().

Definition at line 52 of file TwoDistance.cpp.

References EVAL_INFINITY, StoneBoard::GetEmpty(), HexBoard::GetPosition(), HexAssert, HexEval, INVALID_POINT, and m_brd.

Referenced by ComputeScore().

Definition at line 88 of file TwoDistance.cpp.

References ADJACENT, HexBoard::Cons(), VC::FULL, FULL_VC, VC::IsEmpty(), m_brd, m_ntype, and VCSet::SmallestVC().

Referenced by ComputeDistanceToEdge().

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.

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

Definition at line 108 of file TwoDistance.hpp.

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().

const HexBoard* TwoDistance::m_brd` [private]` |

Definition at line 90 of file TwoDistance.hpp.

Referenced by ComputeDistanceToEdge(), ComputeScores(), Evaluate(), FindBest(), IsAdjacent(), and SetAllToInfinity().

NeighbourType TwoDistance::m_ntype` [private]` |

Definition at line 91 of file TwoDistance.hpp.

Referenced by IsAdjacent().

HexEval TwoDistance::m_score` [private]` |

Definition at line 93 of file TwoDistance.hpp.

Referenced by ComputeScore(), and Score().

HexEval TwoDistance::m_scores[BLACK_AND_WHITE][BITSETSIZE]` [private]` |

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