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