progress.cc Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
lib/eval/ml/progress.cc
Go to the documentation of this file.
1 #include "osl/eval/ml/progress.h"
2
3 osl::misc::CArray<int, 256> osl::eval::ml::ProgressBonus::table;
4
5 int osl::eval::ml::ProgressBonus::eval(Progress16 black,
6 Progress16 white)
7 {
8 return table[index(black, white)];
9 }
10
11 void osl::eval::ml::ProgressBonus::setUp(const Weights &weights)
12 {
13 for (size_t i = 0; i < weights.dimension(); ++i)
14 {
15 table[i] = weights.value(i);
16 }
17
18 for (int black = 0; black < 16; ++black)
19 {
20 for (int white = 0; white < 16; ++white)
21 {
22 if (black <= white)
23 {
24 table[index(Progress16(black), Progress16(white))] =
25 -table[index(Progress16(white), Progress16(black))];
26 }
27 }
28 }
29 }
30
31
32 osl::misc::CArray<int, 256> osl::eval::ml::ProgressAttackDefense::table;
33
34 int osl::eval::ml::ProgressAttackDefense::eval(
35 Progress16 black_attack, Progress16 white_defense,
36 Progress16 white_attack, Progress16 black_defense)
37 {
38 return table[index(black_attack, white_defense)] -
39 table[index(white_attack, black_defense)];
40 }
41
42 void osl::eval::ml::
43 ProgressAttackDefense::setUp(const Weights &weights)
44 {
45 for (size_t i = 0; i < weights.dimension(); ++i)
46 {
47 table[i] = weights.value(i);
48 }
49 }
50
51
52 osl::misc::CArray<int, 65536>
53 osl::eval::ml::ProgressAttackDefenseAll::table;
54
55 int osl::eval::ml::ProgressAttackDefenseAll::eval(
56 Progress16 black_attack, Progress16 white_defense,
57 Progress16 white_attack, Progress16 black_defense)
58 {
59 return table[index(black_attack, white_defense,
60 white_attack, black_defense)];
61 }
62
63 void osl::eval::ml::
64 ProgressAttackDefenseAll::setUp(const Weights &weights)
65 {
66 for (size_t i = 0; i < weights.dimension(); ++i)
67 {
68 table[i] = weights.value(i);
69 }
70 for (int ba = 0; ba < 16; ++ba)
71 {
72 for (int wd = 0; wd < 16; ++wd)
73 {
74 for (int wa = 0; wa < 16; ++wa)
75 {
76 for (int bd = 0; bd < 16; ++bd)
77 {
78 if (ba + wd < wa + bd ||
79 (ba + wd == wa + bd &&
80 ba <= wa))
81 {
82 table[index(Progress16(ba), Progress16(wd),
83 Progress16(wa), Progress16(bd))] =
84 -table[index(Progress16(wa), Progress16(bd),
85 Progress16(ba), Progress16(wd))];
86 }
87 }
88 }
89 }
90 }
91 }