00001
00002
00003
00004
00005
00006
00007 #include "SgSystem.h"
00008 #include "SgSearchValue.h"
00009
00010 #include <algorithm>
00011 #include <iomanip>
00012 #include <limits>
00013 #include <sstream>
00014 #include <math.h>
00015
00016 using namespace std;
00017
00018
00019
00020
00021
00022
00023
00024 string SgSearchValue::ToString(int unitPerPoint) const
00025 {
00026 if (m_value == 0)
00027 return "0";
00028 ostringstream stream;
00029 stream << (m_value > 0 ? "B+" : "W+");
00030 if (IsEstimate())
00031 {
00032 if (unitPerPoint == 1)
00033 stream << (abs(m_value) / unitPerPoint);
00034 else
00035 stream << setprecision(1)
00036 << (static_cast<float>(abs(m_value)) / unitPerPoint);
00037 }
00038 else
00039 {
00040 if (KoLevel() != 0)
00041 stream << "(ko)";
00042 if (Depth() != 0)
00043 {
00044 stream << " (" << Depth() << " moves)";
00045 }
00046 }
00047 return stream.str();
00048 }
00049
00050 bool SgSearchValue::FromString(const string& s)
00051 {
00052 SG_UNUSED(s);
00053 SG_ASSERT(false);
00054 return false;
00055 }
00056
00057 int SgSearchValue::KoLevel() const
00058 {
00059 if (IsEstimate())
00060 return 0;
00061 else
00062 {
00063 int level = (abs(m_value) - 1) / SgSearch::MAX_DEPTH;
00064 return (MAX_LEVEL - 1) - level;
00065 }
00066 }
00067
00068
00069