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