00001
00002
00003 #include "osl/category/ptypePtypeProbTable.h"
00004 #include "osl/category/probTable.tcc"
00005 #include <iostream>
00006
00007 osl::category::
00008 PtypePtypeProbTable::PtypePtypeProbTable(const char *h, const char *n)
00009 : base_t(h,n)
00010 {
00011 }
00012
00013 osl::category::
00014 PtypePtypeProbTable::~PtypePtypeProbTable()
00015 {
00016 }
00017
00018 void osl::category::
00019 PtypePtypeProbTable::show()
00020 {
00021
00022 for (int i=-PieceValueTable::RANGE; i<PieceValueTable::RANGE; i+=64)
00023 {
00024 const int index = getIndex(PAWN, false, ROOK, i);
00025 std::cerr << i << "\t" << index << "\t" << prob[index] << "\n";
00026 std::cerr << PieceValueTable::getIndex(i) << "\n";
00027 }
00028 }
00029
00030 void osl::category::PtypePtypeProbTable::
00031 interpolate()
00032 {
00033 int lastVal = CategoryTraits::maxProb();
00034 for (size_t i=0; i<indexMax(); ++i)
00035 {
00036 if ((i % PieceValueTable::indexMax()) == 0)
00037 lastVal = CategoryTraits::maxProb();
00038 if (prob[i] == 0)
00039 {
00040 prob[i] = lastVal;
00041 }
00042 else
00043 {
00044 lastVal = std::min(prob[i], lastVal);
00045 }
00046 }
00047 }
00048
00049 osl::category::
00050 PtypePtype2ProbTable::PtypePtype2ProbTable(const char *h, const char *n)
00051 : base_t(h,n)
00052 {
00053 }
00054
00055 osl::category::
00056 PtypePtype2ProbTable::~PtypePtype2ProbTable()
00057 {
00058 }
00059
00060 void osl::category::PtypePtype2ProbTable::
00061 interpolate()
00062 {
00063 int lastVal = CategoryTraits::maxProb();
00064 for (size_t i=0; i<indexMax(); ++i)
00065 {
00066 if ((i % PieceValueTable::indexMax()) == 0)
00067 lastVal = CategoryTraits::maxProb();
00068 if (prob[i] == 0)
00069 {
00070
00071
00072
00073
00074
00075
00076 const size_t ignored0 = ((i / PieceValueTableLength) & (~(31*16)))
00077 *PieceValueTableLength + (i % PieceValueTableLength);
00078 if ((i != ignored0) && prob[ignored0] && (lastVal > prob[ignored0]))
00079 {
00080 lastVal = prob[ignored0];
00081 }
00082 const size_t ignored1 = ((ignored0 / PieceValueTableLength) ^ (16*16))
00083 * PieceValueTableLength + (i % PieceValueTableLength);
00084 if ((i != ignored1) && prob[ignored1] && (lastVal > prob[ignored1]))
00085 {
00086 lastVal = prob[ignored1];
00087 }
00088 #if 0
00089
00090
00091
00092 const size_t ptype1base = 2*16*16*PieceValueTableLength;
00093 const Ptype ptype1 = static_cast<Ptype>((ignored0 / ptype1base) & 15);
00094 if (isPiece(ptype1))
00095 {
00096 const size_t unpromote0 = unpromote(ptype1) * ptype1base
00097 + (ignored0 % ptype1base);
00098 if ((i != unpromote0) && prob[unpromote0] && (lastVal > prob[unpromote0]))
00099 {
00100 lastVal = prob[unpromote0];
00101 }
00102 const size_t unpromote1 = unpromote0 + 16*ptype1base;
00103 if ((i != unpromote1) && prob[unpromote1] && (lastVal > prob[unpromote1]))
00104 {
00105 lastVal = prob[unpromote1];
00106 }
00107 }
00108 #endif
00109 prob[i] = lastVal;
00110 }
00111 else
00112 {
00113 lastVal = prob[i];
00114 }
00115 }
00116 }
00117
00118 osl::category::
00119 PtypeValueTable::PtypeValueTable(const char *h, const char *n)
00120 : base_t(h,n)
00121 {
00122 }
00123
00124 osl::category::
00125 PtypeValueTable::~PtypeValueTable()
00126 {
00127 }
00128
00129 void osl::category::PtypeValueTable::
00130 interpolate()
00131 {
00132 int lastVal = CategoryTraits::maxProb();
00133 for (size_t i=0; i<indexMax(); ++i)
00134 {
00135 if ((i % PieceValueTable::indexMax()) == 0)
00136 lastVal = CategoryTraits::maxProb();
00137 if (prob[i] == 0)
00138 {
00139 prob[i] = lastVal;
00140 }
00141 else
00142 {
00143 lastVal = prob[i];
00144 }
00145 }
00146 }
00147
00148
00149
00150
00151
00152