00001 //---------------------------------------------------------------------------- 00002 /** @file GoEyeCount.cpp 00003 See GoEyeCount.h 00004 */ 00005 //---------------------------------------------------------------------------- 00006 00007 #include "SgSystem.h" 00008 #include "GoEyeCount.h" 00009 00010 #include <algorithm> 00011 #include "SgWrite.h" 00012 00013 using std::min; 00014 using std::max; 00015 00016 void GoEyeCount::SetLocalSeki() 00017 { 00018 SetEyes(2, 2); 00019 m_isLocalSeki = true; 00020 m_maybeLocalSeki = true; 00021 } 00022 00023 void GoEyeCount::Normalize() 00024 { 00025 if (m_minEyes > m_maxEyes) 00026 m_maxEyes = m_minEyes; 00027 if (m_minEyes > m_minPotEyes) 00028 m_minPotEyes = m_minEyes; 00029 if (m_maxEyes > m_maxPotEyes) 00030 m_maxPotEyes = m_maxEyes; 00031 if (m_minPotEyes > m_maxPotEyes) 00032 m_maxPotEyes = m_minPotEyes; 00033 00034 if (m_minEyes > 2) 00035 m_minEyes = 2; 00036 if (m_maxEyes > 2) 00037 m_maxEyes = 2; 00038 if (m_minPotEyes > 2) 00039 m_minPotEyes = 2; 00040 if (m_maxPotEyes > 2) 00041 m_maxPotEyes = 2; 00042 } 00043 00044 void GoEyeCount::AddIndependent(const GoEyeCount& from) 00045 { 00046 m_minEyes += from.m_minEyes; 00047 m_maxEyes += from.m_maxEyes; 00048 m_minEyes = max(m_minEyes, min(m_minPotEyes, from.m_minPotEyes)); 00049 m_maxEyes = max(m_maxEyes, min(m_maxPotEyes, from.m_maxPotEyes)); 00050 m_minPotEyes += from.m_minPotEyes; 00051 m_maxPotEyes += from.m_maxPotEyes; 00052 } 00053 00054 void GoEyeCount::NumericalAdd(const GoEyeCount& from) 00055 { 00056 m_minEyes += from.m_minEyes; 00057 m_maxEyes += from.m_maxEyes; 00058 m_minPotEyes += from.m_minPotEyes; 00059 m_maxPotEyes += from.m_maxPotEyes; 00060 } 00061 00062 void GoEyeCount::AddPotential(const GoEyeCount& from) 00063 { 00064 m_minPotEyes += from.MinPotEyes(); 00065 m_maxPotEyes += from.MaxPotEyes(); 00066 } 00067 00068 std::ostream& operator<<(std::ostream& stream, const GoEyeCount& s) 00069 { 00070 stream << SgWriteLabel("Eyes") 00071 << '[' << s.MinEyes() 00072 << ".." << s.MaxEyes() << "]\n" 00073 << SgWriteLabel("PotEyes") 00074 << '[' << s.MinPotEyes() 00075 << ".." << s.MaxPotEyes() << "]\n" 00076 << SgWriteLabel("LocalSeki") << s.IsLocalSeki() << '\n' 00077 << SgWriteLabel("MaybeLocalSeki") << s.MaybeLocalSeki() 00078 << '\n'; 00079 return stream; 00080 } 00081 00082 //---------------------------------------------------------------------------- 00083