00001 //---------------------------------------------------------------------------- 00002 /** @file IcePatternSet.cpp 00003 */ 00004 //---------------------------------------------------------------------------- 00005 00006 #include "IcePatternSet.hpp" 00007 00008 using namespace benzene; 00009 00010 //---------------------------------------------------------------------------- 00011 00012 IcePatternSet::IcePatternSet() 00013 { 00014 } 00015 00016 IcePatternSet::~IcePatternSet() 00017 { 00018 } 00019 00020 void IcePatternSet::LoadPatterns(const boost::filesystem::path& file) 00021 { 00022 boost::filesystem::path normalizedFile = file; 00023 normalizedFile.normalize(); 00024 std::string nativeFile = normalizedFile.native_file_string(); 00025 00026 std::vector<Pattern> patterns; 00027 Pattern::LoadPatternsFromFile(nativeFile.c_str(), patterns); 00028 00029 LogFine() << "IcePatternSet: " 00030 << "Read " << patterns.size() << " patterns " 00031 << "from '" << nativeFile << "'." << '\n'; 00032 00033 for (std::size_t i = 0; i < patterns.size(); i++) 00034 { 00035 Pattern p(patterns[i]); 00036 00037 switch(p.getType()) { 00038 case Pattern::DEAD: 00039 m_dead.push_back(p); 00040 break; 00041 00042 case Pattern::CAPTURED: 00043 // WHITE is first!! 00044 m_captured[WHITE].push_back(p); 00045 p.flipColors(); 00046 m_captured[BLACK].push_back(p); 00047 break; 00048 00049 case Pattern::PERMANENTLY_INFERIOR: 00050 // WHITE is first!! 00051 m_permanently_inferior[WHITE].push_back(p); 00052 p.flipColors(); 00053 m_permanently_inferior[BLACK].push_back(p); 00054 break; 00055 00056 case Pattern::MUTUAL_FILLIN: 00057 // BLACK is first; should maybe be WHITE to match other fillin? 00058 m_mutual_fillin[BLACK].push_back(p); 00059 p.flipColors(); 00060 m_mutual_fillin[WHITE].push_back(p); 00061 break; 00062 00063 case Pattern::VULNERABLE: 00064 m_vulnerable[BLACK].push_back(p); 00065 p.flipColors(); 00066 m_vulnerable[WHITE].push_back(p); 00067 break; 00068 00069 case Pattern::REVERSIBLE: 00070 m_reversible[BLACK].push_back(p); 00071 p.flipColors(); 00072 m_reversible[WHITE].push_back(p); 00073 break; 00074 00075 case Pattern::DOMINATED: 00076 m_dominated[BLACK].push_back(p); 00077 p.flipColors(); 00078 m_dominated[WHITE].push_back(p); 00079 break; 00080 00081 default: 00082 LogSevere() << "Pattern type = " << p.getType() << '\n'; 00083 HexAssert(false); 00084 } 00085 } 00086 00087 m_hashed_dead.hash(m_dead); 00088 for (BWIterator it; it; ++it) 00089 { 00090 m_hashed_captured[*it].hash(m_captured[*it]); 00091 m_hashed_permanently_inferior[*it].hash(m_permanently_inferior[*it]); 00092 m_hashed_mutual_fillin[*it].hash(m_mutual_fillin[*it]); 00093 m_hashed_vulnerable[*it].hash(m_vulnerable[*it]); 00094 m_hashed_reversible[*it].hash(m_reversible[*it]); 00095 m_hashed_dominated[*it].hash(m_dominated[*it]); 00096 } 00097 } 00098 00099 //----------------------------------------------------------------------------