Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgSearchValue Class Reference

#include <SgSearchValue.h>

List of all members.


Detailed Description

Value used in search tasks derived from class SgSearch.

There's a range of values that indicate that the problem has been solved (at a certain depth), a range of values for solutions that involve ko, and a range of values for problems that have not been solved yet. Value is always stored with positive values being good for black, negative values being good for white.

    int v = Board().ToPlay() == SG_WHITE ? -value : +value;
    

Definition at line 27 of file SgSearchValue.h.

Public Types

 MAX_LEVEL = 125
 MAX_VALUE = MAX_LEVEL * SgSearch::MAX_DEPTH
 The best possible search result - highest possible value.
 MIN_VALUE = -MAX_VALUE
 The worst possible search result.
 MAX_KO_LEVEL = 3
 The maximum number of Ko recaptures allowed in a search.
 KO_VALUE = MAX_VALUE - SgSearch::MAX_DEPTH
 KO_VALUE is the result for win by ko.
 MIN_PROVEN_VALUE
 MIN_PROVEN_VALUE is the lowest score that indicates a proven win.
enum  {
  MAX_LEVEL = 125, MAX_VALUE = MAX_LEVEL * SgSearch::MAX_DEPTH, MIN_VALUE = -MAX_VALUE, MAX_KO_LEVEL = 3,
  KO_VALUE = MAX_VALUE - SgSearch::MAX_DEPTH, MIN_PROVEN_VALUE
}

Public Member Functions

 SgSearchValue ()
 SgSearchValue (int v)
 SgSearchValue (SgBlackWhite goodForPlayer, int depth)
 SgSearchValue (SgBlackWhite goodForPlayer, int depth, int koLevel)
 operator int () const
 Return current value as an integer.
int Depth () const
bool FromString (const std::string &s)
 Convert 'string' to a value and set this value.
bool IsEstimate () const
bool IsKoValue () const
bool IsPositive () const
bool IsSureValue () const
int KoLevel () const
void SetValueForPlayer (SgBlackWhite player)
int ValueForBlack () const
int ValueForPlayer (SgBlackWhite player) const
int ValueForWhite () const
std::string ToString (int unitPerPoint=1) const
 Set '*s' to the string for this value, e.g.

Static Public Member Functions

static bool IsSolved (int value)
 is value == +MAX_VALUE or -MAX_VALUE?
static bool SolvedValue (bool isWin)
 return +MAX_VALUE for win, -MAX_VALUE for loss

Private Attributes

int m_value


Member Enumeration Documentation

anonymous enum

Enumerator:
MAX_LEVEL 
MAX_VALUE  The best possible search result - highest possible value.

A win in n ply is encoded with a value of MAX_VALUE - n. A loss is encoded as -value if the win would be encoded as value. MAX_VALUE==32000.

MIN_VALUE  The worst possible search result.

All search results are in the range [MIN_VALUE..MAX_VALUE].

MAX_KO_LEVEL  The maximum number of Ko recaptures allowed in a search.
KO_VALUE  KO_VALUE is the result for win by ko.

Similarly with MAX_VALUE, a win by Ko in n ply is encoded as KO_VALUE - n. KO_VALUE==32000 - 256 = 31744.

MIN_PROVEN_VALUE  MIN_PROVEN_VALUE is the lowest score that indicates a proven win.

1. values in the range [MIN_VALUE..-MIN_PROVEN_VALUE] are proven losses (possibly by ko). 2. values in the range [-MIN_PROVEN_VALUE+1..MIN_PROVEN_VALUE-1] are heuristic scores. 3. values in range [MIN_PROVEN_VALUE..MAX_VALUE] are proven wins (possibly by ko).

Definition at line 30 of file SgSearchValue.h.


Constructor & Destructor Documentation

SgSearchValue::SgSearchValue (  ) 

Definition at line 121 of file SgSearchValue.h.

SgSearchValue::SgSearchValue ( int  v  )  [explicit]

Definition at line 125 of file SgSearchValue.h.

References MAX_VALUE, and SG_ASSERT.

SgSearchValue::SgSearchValue ( SgBlackWhite  goodForPlayer,
int  depth 
)

Definition at line 131 of file SgSearchValue.h.

References Depth(), KoLevel(), SgSearch::MAX_DEPTH, SetValueForPlayer(), SG_ASSERT, and SG_ASSERT_BW.

SgSearchValue::SgSearchValue ( SgBlackWhite  goodForPlayer,
int  depth,
int  koLevel 
)

Definition at line 142 of file SgSearchValue.h.

References Depth(), KoLevel(), SgSearch::MAX_DEPTH, MAX_KO_LEVEL, SetValueForPlayer(), SG_ASSERT, and SG_ASSERT_BW.


Member Function Documentation

int SgSearchValue::Depth (  )  const

Definition at line 159 of file SgSearchValue.h.

References IsEstimate(), m_value, and SgSearch::MAX_DEPTH.

Referenced by SgSearchValue(), and ToString().

bool SgSearchValue::FromString ( const std::string &  s  ) 

Convert 'string' to a value and set this value.

Return true if the string could be converted to a valid value, otherwise false.

Definition at line 50 of file SgSearchValue.cpp.

References SG_ASSERT, and SG_UNUSED().

bool SgSearchValue::IsEstimate (  )  const

Definition at line 167 of file SgSearchValue.h.

References m_value, and MIN_PROVEN_VALUE.

Referenced by Depth(), KoLevel(), and ToString().

bool SgSearchValue::IsKoValue (  )  const

Definition at line 172 of file SgSearchValue.h.

References IsSureValue(), KO_VALUE, and m_value.

bool SgSearchValue::IsPositive (  )  const

Definition at line 177 of file SgSearchValue.h.

References m_value.

bool SgSearchValue::IsSolved ( int  value  )  [static]

is value == +MAX_VALUE or -MAX_VALUE?

Definition at line 187 of file SgSearchValue.h.

References MAX_VALUE.

bool SgSearchValue::IsSureValue (  )  const

Definition at line 182 of file SgSearchValue.h.

References m_value, and MIN_PROVEN_VALUE.

Referenced by IsKoValue().

int SgSearchValue::KoLevel (  )  const

Definition at line 57 of file SgSearchValue.cpp.

References IsEstimate(), m_value, SgSearch::MAX_DEPTH, and MAX_LEVEL.

Referenced by SgSearchValue(), and ToString().

SgSearchValue::operator int (  )  const

Return current value as an integer.

Definition at line 154 of file SgSearchValue.h.

References m_value.

void SgSearchValue::SetValueForPlayer ( SgBlackWhite  player  ) 

Definition at line 197 of file SgSearchValue.h.

References m_value, and SG_WHITE.

Referenced by SgSearchValue().

bool SgSearchValue::SolvedValue ( bool  isWin  )  [static]

return +MAX_VALUE for win, -MAX_VALUE for loss

Definition at line 192 of file SgSearchValue.h.

References MAX_VALUE.

string SgSearchValue::ToString ( int  unitPerPoint = 1  )  const

Set '*s' to the string for this value, e.g.

"B+3.5", "W+20", or "W+(ko)[12]". The value is divided by 'unitPerPoint' to determine the number of points.

Definition at line 24 of file SgSearchValue.cpp.

References Depth(), IsEstimate(), KoLevel(), and m_value.

int SgSearchValue::ValueForBlack (  )  const

Definition at line 203 of file SgSearchValue.h.

References m_value.

int SgSearchValue::ValueForPlayer ( SgBlackWhite  player  )  const

Definition at line 208 of file SgSearchValue.h.

References m_value, SG_ASSERT_BW, and SG_WHITE.

int SgSearchValue::ValueForWhite (  )  const

Definition at line 214 of file SgSearchValue.h.

References m_value.


Member Data Documentation

int SgSearchValue::m_value [private]

Definition at line 118 of file SgSearchValue.h.

Referenced by Depth(), IsEstimate(), IsKoValue(), IsPositive(), IsSureValue(), KoLevel(), operator int(), SetValueForPlayer(), ToString(), ValueForBlack(), ValueForPlayer(), and ValueForWhite().


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


17 Jun 2010 Doxygen 1.4.7