progress.cc
Go to the documentation of this file.
00001 #include "osl/eval/ml/progress.h"
00002 
00003 osl::misc::CArray<int, 256> osl::eval::ml::ProgressBonus::table;
00004 
00005 int osl::eval::ml::ProgressBonus::eval(Progress16 black,
00006                                                  Progress16 white)
00007 {
00008   return table[index(black, white)];
00009 }
00010 
00011 void osl::eval::ml::ProgressBonus::setUp(const Weights &weights)
00012 {
00013   for (size_t i = 0; i < weights.dimension(); ++i)
00014   {
00015     table[i] = weights.value(i);
00016   }
00017 
00018   for (int black = 0; black < 16; ++black)
00019   {
00020     for (int white = 0; white < 16; ++white)
00021     {
00022       if (black <= white)
00023       {
00024         table[index(Progress16(black), Progress16(white))] =
00025           -table[index(Progress16(white), Progress16(black))];
00026       }
00027     }
00028   }
00029 }
00030 
00031 
00032 osl::misc::CArray<int, 256> osl::eval::ml::ProgressAttackDefense::table;
00033 
00034 int osl::eval::ml::ProgressAttackDefense::eval(
00035   Progress16 black_attack, Progress16 white_defense,
00036   Progress16 white_attack, Progress16 black_defense)
00037 {
00038   return table[index(black_attack, white_defense)] -
00039     table[index(white_attack, black_defense)];
00040 }
00041 
00042 void osl::eval::ml::
00043 ProgressAttackDefense::setUp(const Weights &weights)
00044 {
00045   for (size_t i = 0; i < weights.dimension(); ++i)
00046   {
00047     table[i] = weights.value(i);
00048   }
00049 }
00050 
00051 
00052 osl::misc::CArray<int, 65536>
00053 osl::eval::ml::ProgressAttackDefenseAll::table;
00054 
00055 int osl::eval::ml::ProgressAttackDefenseAll::eval(
00056   Progress16 black_attack, Progress16 white_defense,
00057   Progress16 white_attack, Progress16 black_defense)
00058 {
00059   return table[index(black_attack, white_defense,
00060                      white_attack, black_defense)];
00061 }
00062 
00063 void osl::eval::ml::
00064 ProgressAttackDefenseAll::setUp(const Weights &weights)
00065 {
00066   for (size_t i = 0; i < weights.dimension(); ++i)
00067   {
00068     table[i] = weights.value(i);
00069   }
00070   for (int ba = 0; ba < 16; ++ba)
00071   {
00072     for (int wd = 0; wd < 16; ++wd)
00073     {
00074       for (int wa = 0; wa < 16; ++wa)
00075       {
00076         for (int bd = 0; bd < 16; ++bd)
00077         {
00078           if (ba + wd < wa + bd ||
00079               (ba + wd == wa + bd &&
00080                ba <= wa))
00081           {
00082             table[index(Progress16(ba), Progress16(wd),
00083                         Progress16(wa), Progress16(bd))] =
00084               -table[index(Progress16(wa), Progress16(bd),
00085                            Progress16(ba), Progress16(wd))];
00086           }
00087         }
00088       }
00089     }
00090   }
00091 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines