Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

ICEngine Class Reference

Inferior Cell Engine. More...

#include <ICEngine.hpp>

List of all members.

Public Member Functions

 ICEngine ()
 Constructor.
virtual ~ICEngine ()
 Destructor.
Board modifying functions of ICEngine

void ComputeInferiorCells (HexColor color, Groups &board, PatternState &pastate, InferiorCells &out) const
 Categorizes cells as dead, captured, etc.
void ComputeFillin (HexColor color, Groups &board, PatternState &pastate, InferiorCells &out, HexColorSet colors_to_capture=ALL_COLORS) const
 Computes fill-in; dominated and vulnerable cells are not stored.
std::size_t ComputeDeadCaptured (Groups &board, PatternState &pastate, InferiorCells &inf, HexColorSet colors_to_capture) const
 Computes only the dead and captured cells; board will be modified to have the captured cells filled-in.
Methods to find various types of inferior cells

bitset_t FindDead (const PatternState &board, const bitset_t &consider) const
 Returns the dead cells among the consider set.
void FindVulnerable (const PatternState &board, HexColor color, const bitset_t &consider, InferiorCells &inf) const
 Finds vulnerable cells for color among the consider set.
void FindReversible (const PatternState &board, HexColor color, const bitset_t &consider, InferiorCells &inf) const
 Finds reversible cells for color among the consider set.
void FindDominated (const PatternState &board, HexColor color, const bitset_t &consider, InferiorCells &inf) const
 Finds dominated cells for color among the consider set using local patterns.
void FindDominatedOnCell (const PatternState &pastate, HexColor color, HexPoint cell, PatternHits &hits) const
 Finds all dominated cell patterns for color on this one cell.
void FindHandCodedDominated (const StoneBoard &board, HexColor color, const bitset_t &consider, InferiorCells &inf) const
 Finds cells dominated via hand-coded patterns.
bitset_t FindCaptured (const PatternState &board, HexColor color, const bitset_t &consider) const
 Finds captured cells for color among the consider set using local patterns.
bitset_t FindPermanentlyInferior (const PatternState &board, HexColor color, const bitset_t &consider, bitset_t &carrier) const
 Finds the permanently inferior cells for color among consider set using local patterns.
void FindMutualFillin (const PatternState &board, HexColor color, const bitset_t &consider, bitset_t &carrier, bitset_t *mut) const
 Finds the mutual fillin cells for color among consider set using local patterns.
Parameters

bool FindPresimplicialPairs () const
void SetFindPresimplicialPairs (bool enable)
bool FindPermanentlyInferior () const
void SetFindPermanentlyInferior (bool enable)
bool FindMutualFillin () const
void SetFindMutualFillin (bool enable)
bool FindAllPatternKillers () const
 Find all killers for each cell if true, stop at first if false.
void SetFindAllPatternKillers (bool enable)
bool FindAllPatternReversers () const
 Find all reversers for each cell if true, stop at first if false.
void SetFindAllPatternReversers (bool enable)
bool FindAllPatternDominators () const
 Find all dominators for each cell if true, stop at first if false.
void SetFindAllPatternDominators (bool enable)
bool UseHandCodedPatterns () const
void SetUseHandCodedPatterns (bool enable)
bool BackupOpponentDead () const
 Performs a 1-ply search for the opponent: any dead stones created in child states are backed-up as vulnerable cells in this state, with the killer set to all the created fillin.
void SetBackupOpponentDead (bool enable)
bool FindThreeSidedDeadRegions () const
void SetFindThreeSidedDeadRegions (bool enable)
bool IterativeDeadRegions () const
 Performs a dead region sweep on each iteration of the fillin loop if true, only at the end if false.
void SetIterativeDeadRegions (bool enable)

Private Member Functions

void LoadPatterns ()
 Loads local patterns from "ice-pattern-file".
void LoadHandCodedPatterns ()
 Creates the set of hand-coded patterns.
std::size_t FillinPermanentlyInferior (Groups &groups, PatternState &board, HexColor color, InferiorCells &out, HexColorSet colors_to_capture) const
 Calls FindPermanentlyInferior() and adds any found to the board and the set of inferior cells.x.
std::size_t FillInMutualFillin (Groups &groups, PatternState &board, HexColor color, InferiorCells &out, HexColorSet colors_to_capture) const
 Calls FindMutualFillin() and adds any found to the board and the set of inferior cells.x.
std::size_t CliqueCutsetDead (Groups &groups, PatternState &pastate, InferiorCells &out) const
 Calls ComputeDeadRegions() and FindThreeSetCliques() and adds fill-in to board and set of inferior cells.
std::size_t BackupOpponentDead (HexColor color, const StoneBoard &board, PatternState &pastate, InferiorCells &out) const
 For each empty cell on the board, the move is played with the opponent's stone (ie, !color) and the fill-in is computed.
std::size_t FillInVulnerable (HexColor color, Groups &groups, PatternState &pastate, InferiorCells &inf, HexColorSet colors_to_capture) const
 Finds vulnerable cells for color and finds presimplicial pairs and fills them in for the other color.
void CheckHandCodedDominates (const StoneBoard &brd, HexColor color, const HandCodedPattern &pattern, const bitset_t &consider, InferiorCells &inf) const
 Handles color flipping/rotations for this hand-coded pattern.

Private Attributes

bool m_find_presimplicial_pairs
bool m_find_permanently_inferior
bool m_find_mutual_fillin
bool m_find_all_pattern_killers
bool m_find_all_pattern_reversers
bool m_find_all_pattern_dominators
bool m_use_handcoded_patterns
bool m_backup_opponent_dead
bool m_find_three_sided_dead_regions
bool m_iterative_dead_regions
std::vector< HandCodedPatternm_hand_coded
IcePatternSet m_patterns

Detailed Description

Inferior Cell Engine.

Finds inferior cells on a given boardstate.

ICE is thread-safe. Multiple threads can use the same instance of ICEngine without any problems.

Definition at line 26 of file ICEngine.hpp.


Constructor & Destructor Documentation

ICEngine::ICEngine (  ) 

Constructor.

Definition at line 490 of file ICEngine.cpp.

References LoadHandCodedPatterns(), and LoadPatterns().

ICEngine::~ICEngine (  )  [virtual]

Destructor.

Definition at line 506 of file ICEngine.cpp.


Member Function Documentation

std::size_t ICEngine::BackupOpponentDead ( HexColor  color,
const StoneBoard board,
PatternState pastate,
InferiorCells out 
) const [private]

For each empty cell on the board, the move is played with the opponent's stone (ie, !color) and the fill-in is computed.

Any dead cells in this state are backed-up as vulnerable cells in the original state, with the set of captured stones as the vulnerable-carrier. This can be moderately expensive.

Todo:
Link to the "ice-backup-opp-dead" option, or link it's documentation here.

Todo:
Add if already vulnerable?

Definition at line 803 of file ICEngine.cpp.

References InferiorCells::AddVulnerable(), BLACK, GroupBuilder::Build(), ComputeFillin(), PatternState::CopyState(), InferiorCells::Dead(), InferiorCells::Dominated(), InferiorCells::Fillin(), StoneBoard::GetBlack(), StoneBoard::GetEmpty(), StoneBoard::GetWhite(), StoneBoard::PlayMove(), benzene_bitset< _Nb >::reset(), InferiorCells::Reversible(), StoneBoard::SetColor(), StoneBoard::StartNewGame(), benzene_bitset< _Nb >::test(), PatternState::Update(), InferiorCells::Vulnerable(), and WHITE.

bool ICEngine::BackupOpponentDead (  )  const [inline]

Performs a 1-ply search for the opponent: any dead stones created in child states are backed-up as vulnerable cells in this state, with the killer set to all the created fillin.

Definition at line 333 of file ICEngine.hpp.

References m_backup_opponent_dead.

Referenced by ComputeInferiorCells(), and HexEnvironmentCommands::ParamICE().

void ICEngine::CheckHandCodedDominates ( const StoneBoard brd,
HexColor  color,
const HandCodedPattern pattern,
const bitset_t consider,
InferiorCells inf 
) const [private]
std::size_t ICEngine::CliqueCutsetDead ( Groups groups,
PatternState pastate,
InferiorCells out 
) const [private]

Calls ComputeDeadRegions() and FindThreeSetCliques() and adds fill-in to board and set of inferior cells.

Definition at line 691 of file ICEngine.cpp.

References StoneBoard::AddColor(), InferiorCells::AddDead(), benzene_bitset< _Nb >::any(), Groups::Board(), GroupBuilder::Build(), benzene_bitset< _Nb >::count(), DEAD_COLOR, m_find_three_sided_dead_regions, and PatternState::Update().

Referenced by ComputeFillin().

std::size_t ICEngine::ComputeDeadCaptured ( Groups board,
PatternState pastate,
InferiorCells inf,
HexColorSet  colors_to_capture 
) const

Computes only the dead and captured cells; board will be modified to have the captured cells filled-in.

Returns number of cells filled-in.

Todo:
This can be optimized quite a bit.

Definition at line 533 of file ICEngine.cpp.

References InferiorCells::AddCaptured(), StoneBoard::AddColor(), InferiorCells::AddDead(), benzene_bitset< _Nb >::any(), BLACK, Groups::Board(), GroupBuilder::Build(), benzene_bitset< _Nb >::count(), DEAD_COLOR, FindCaptured(), FindDead(), StoneBoard::GetEmpty(), HexColorSetUtil::InSet(), benzene_bitset< _Nb >::none(), PatternState::Update(), and WHITE.

Referenced by ComputeFillin().

void ICEngine::ComputeFillin ( HexColor  color,
Groups board,
PatternState pastate,
InferiorCells out,
HexColorSet  colors_to_capture = ALL_COLORS 
) const
void ICEngine::ComputeInferiorCells ( HexColor  color,
Groups board,
PatternState pastate,
InferiorCells out 
) const
std::size_t ICEngine::FillInMutualFillin ( Groups groups,
PatternState board,
HexColor  color,
InferiorCells out,
HexColorSet  colors_to_capture 
) const [private]

Calls FindMutualFillin() and adds any found to the board and the set of inferior cells.x.

Can only use mutual fillin when both colours can be captured.

Note: mutual fillin carrier is same for both colors (* cells).

Definition at line 622 of file ICEngine.cpp.

References StoneBoard::AddColor(), InferiorCells::AddMutualFillin(), BLACK, BLACK_AND_WHITE, Groups::Board(), GroupBuilder::Build(), FindMutualFillin(), StoneBoard::GetEmpty(), HexAssert, HexColorSetUtil::InSet(), m_find_mutual_fillin, PatternState::Update(), and WHITE.

Referenced by ComputeFillin().

std::size_t ICEngine::FillinPermanentlyInferior ( Groups groups,
PatternState board,
HexColor  color,
InferiorCells out,
HexColorSet  colors_to_capture 
) const [private]
std::size_t ICEngine::FillInVulnerable ( HexColor  color,
Groups groups,
PatternState pastate,
InferiorCells inf,
HexColorSet  colors_to_capture 
) const [private]

Finds vulnerable cells for color and finds presimplicial pairs and fills them in for the other color.

Simplicial stones will be added as dead and played to the board as DEAD_COLOR.

Definition at line 657 of file ICEngine.cpp.

References InferiorCells::AddCaptured(), StoneBoard::AddColor(), benzene_bitset< _Nb >::any(), Groups::Board(), GroupBuilder::Build(), InferiorCells::ClearVulnerable(), benzene_bitset< _Nb >::count(), InferiorCells::Dead(), InferiorCells::FindPresimplicialPairs(), FindVulnerable(), StoneBoard::GetEmpty(), HexColorSetUtil::InSet(), and PatternState::Update().

Referenced by ComputeFillin().

bool ICEngine::FindAllPatternDominators (  )  const [inline]

Find all dominators for each cell if true, stop at first if false.

Definition at line 313 of file ICEngine.hpp.

References m_find_all_pattern_dominators.

Referenced by HexEnvironmentCommands::ParamICE().

bool ICEngine::FindAllPatternKillers (  )  const [inline]

Find all killers for each cell if true, stop at first if false.

Definition at line 293 of file ICEngine.hpp.

References m_find_all_pattern_killers.

Referenced by HexEnvironmentCommands::ParamICE().

bool ICEngine::FindAllPatternReversers (  )  const [inline]

Find all reversers for each cell if true, stop at first if false.

Definition at line 303 of file ICEngine.hpp.

References m_find_all_pattern_reversers.

bitset_t ICEngine::FindCaptured ( const PatternState board,
HexColor  color,
const bitset_t consider 
) const

Finds captured cells for color among the consider set using local patterns.

Definition at line 856 of file ICEngine.cpp.

References IcePatternSet::HashedCaptured(), HexAssert, m_patterns, PatternState::MatchOnCell(), benzene_bitset< _Nb >::set(), PatternState::STOP_AT_FIRST_HIT, and benzene_bitset< _Nb >::test().

Referenced by ComputeDeadCaptured().

bitset_t ICEngine::FindDead ( const PatternState board,
const bitset_t consider 
) const

Returns the dead cells among the consider set.

Definition at line 850 of file ICEngine.cpp.

References IcePatternSet::HashedDead(), m_patterns, and PatternState::MatchOnBoard().

Referenced by ComputeDeadCaptured().

void ICEngine::FindDominated ( const PatternState board,
HexColor  color,
const bitset_t consider,
InferiorCells inf 
) const
void ICEngine::FindDominatedOnCell ( const PatternState pastate,
HexColor  color,
HexPoint  cell,
PatternHits hits 
) const

Finds all dominated cell patterns for color on this one cell.

Definition at line 1046 of file ICEngine.cpp.

References IcePatternSet::HashedDominated(), m_patterns, PatternState::MATCH_ALL, and PatternState::MatchOnCell().

Referenced by BenzeneHtpEngine::CmdComputeDominatedOnCell().

void ICEngine::FindHandCodedDominated ( const StoneBoard board,
HexColor  color,
const bitset_t consider,
InferiorCells inf 
) const

Finds cells dominated via hand-coded patterns.

Definition at line 1056 of file ICEngine.cpp.

References CheckHandCodedDominates(), StoneBoard::Height(), m_hand_coded, and StoneBoard::Width().

Referenced by FindDominated().

bool ICEngine::FindMutualFillin (  )  const [inline]
Todo:
Document mutual fillin.

Definition at line 283 of file ICEngine.hpp.

References m_find_mutual_fillin.

Referenced by FillInMutualFillin().

void ICEngine::FindMutualFillin ( const PatternState board,
HexColor  color,
const bitset_t consider,
bitset_t carrier,
bitset_t mut 
) const

Finds the mutual fillin cells for color among consider set using local patterns.

Ensure this mutual fillin pattern does not interfere with any other already-added mutual fillin.

The mutual fillin can be added.

Definition at line 906 of file ICEngine.cpp.

References IcePatternSet::HashedMutualFillin(), HexAssert, m_patterns, PatternState::MatchOnCell(), benzene_bitset< _Nb >::set(), and PatternState::STOP_AT_FIRST_HIT.

bool ICEngine::FindPermanentlyInferior (  )  const [inline]
Todo:
Document permanently inferior cells.

Definition at line 273 of file ICEngine.hpp.

References m_find_permanently_inferior.

Referenced by FillinPermanentlyInferior().

bitset_t ICEngine::FindPermanentlyInferior ( const PatternState board,
HexColor  color,
const bitset_t consider,
bitset_t carrier 
) const
bool ICEngine::FindPresimplicialPairs (  )  const [inline]
Todo:
Document what presimplicial pairs are!

Definition at line 263 of file ICEngine.hpp.

References m_find_presimplicial_pairs.

Referenced by HexEnvironmentCommands::ParamICE().

void ICEngine::FindReversible ( const PatternState board,
HexColor  color,
const bitset_t consider,
InferiorCells inf 
) const
bool ICEngine::FindThreeSidedDeadRegions (  )  const [inline]
Todo:
Document three sided dead regions.

Definition at line 343 of file ICEngine.hpp.

References m_find_three_sided_dead_regions.

Referenced by HexEnvironmentCommands::ParamICE().

void ICEngine::FindVulnerable ( const PatternState board,
HexColor  color,
const bitset_t consider,
InferiorCells inf 
) const
bool ICEngine::IterativeDeadRegions (  )  const [inline]

Performs a dead region sweep on each iteration of the fillin loop if true, only at the end if false.

Todo:
Link to fillin algo documentation!

Definition at line 353 of file ICEngine.hpp.

References m_iterative_dead_regions.

Referenced by HexEnvironmentCommands::ParamICE().

void ICEngine::LoadHandCodedPatterns (  )  [private]

Creates the set of hand-coded patterns.

Definition at line 513 of file ICEngine.cpp.

References HandCodedPattern::CreatePatterns(), LogFine(), and m_hand_coded.

Referenced by ICEngine().

void ICEngine::LoadPatterns (  )  [private]

Loads local patterns from "ice-pattern-file".

Definition at line 521 of file ICEngine.cpp.

References IcePatternSet::LoadPatterns(), LogWarning(), and m_patterns.

Referenced by ICEngine().

void ICEngine::SetBackupOpponentDead ( bool  enable  )  [inline]
See also:
BackupOpponentDead()

Definition at line 338 of file ICEngine.hpp.

References m_backup_opponent_dead.

Referenced by HexEnvironmentCommands::ParamICE().

void ICEngine::SetFindAllPatternDominators ( bool  enable  )  [inline]
See also:
FindAllPatternDominators()

Definition at line 318 of file ICEngine.hpp.

References m_find_all_pattern_dominators.

Referenced by HexEnvironmentCommands::ParamICE().

void ICEngine::SetFindAllPatternKillers ( bool  enable  )  [inline]
See also:
FindAllPatternKillers()

Definition at line 298 of file ICEngine.hpp.

References m_find_all_pattern_killers.

Referenced by HexEnvironmentCommands::ParamICE().

void ICEngine::SetFindAllPatternReversers ( bool  enable  )  [inline]
See also:
FindAllPatternReversers()

Definition at line 308 of file ICEngine.hpp.

References m_find_all_pattern_reversers.

void ICEngine::SetFindMutualFillin ( bool  enable  )  [inline]
See also:
FindMutualFillin()

Definition at line 288 of file ICEngine.hpp.

References m_find_mutual_fillin.

void ICEngine::SetFindPermanentlyInferior ( bool  enable  )  [inline]
See also:
FindPermanentlyInferior()

Definition at line 278 of file ICEngine.hpp.

References m_find_permanently_inferior.

Referenced by HexEnvironmentCommands::ParamICE().

void ICEngine::SetFindPresimplicialPairs ( bool  enable  )  [inline]
See also:
FindPresimplicialPairs()

Definition at line 268 of file ICEngine.hpp.

References m_find_presimplicial_pairs.

Referenced by HexEnvironmentCommands::ParamICE().

void ICEngine::SetFindThreeSidedDeadRegions ( bool  enable  )  [inline]
void ICEngine::SetIterativeDeadRegions ( bool  enable  )  [inline]
See also:
IterativeDeadRegions()

Definition at line 358 of file ICEngine.hpp.

References m_iterative_dead_regions.

Referenced by HexEnvironmentCommands::ParamICE().

void ICEngine::SetUseHandCodedPatterns ( bool  enable  )  [inline]
See also:
UseHandCodedPatterns()

Definition at line 328 of file ICEngine.hpp.

References m_use_handcoded_patterns.

Referenced by HexEnvironmentCommands::ParamICE().

bool ICEngine::UseHandCodedPatterns (  )  const [inline]
Todo:
Document hand coded patterns.

Definition at line 323 of file ICEngine.hpp.

References m_use_handcoded_patterns.

Referenced by HexEnvironmentCommands::ParamICE().


Member Data Documentation

See also:
FindMutualFillin()

Definition at line 205 of file ICEngine.hpp.

Referenced by FillInMutualFillin(), FindMutualFillin(), and SetFindMutualFillin().

See also:
FindPresimplicialPairs()

Definition at line 199 of file ICEngine.hpp.

Referenced by FindPresimplicialPairs(), and SetFindPresimplicialPairs().

std::vector<HandCodedPattern> ICEngine::m_hand_coded [private]

Definition at line 228 of file ICEngine.hpp.

Referenced by FindHandCodedDominated(), and LoadHandCodedPatterns().


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


6 Jan 2011 Doxygen 1.6.3