File: progress.cc

package info (click to toggle)
libosl 0.6.0-3.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 148,792 kB
  • ctags: 151,985
  • sloc: cpp: 131,133; ansic: 7,228; ruby: 1,290; makefile: 569; perl: 309; sh: 35
file content (91 lines) | stat: -rw-r--r-- 2,107 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "osl/eval/ml/progress.h"

osl::misc::CArray<int, 256> osl::eval::ml::ProgressBonus::table;

int osl::eval::ml::ProgressBonus::eval(Progress16 black,
						 Progress16 white)
{
  return table[index(black, white)];
}

void osl::eval::ml::ProgressBonus::setUp(const Weights &weights)
{
  for (size_t i = 0; i < weights.dimension(); ++i)
  {
    table[i] = weights.value(i);
  }

  for (int black = 0; black < 16; ++black)
  {
    for (int white = 0; white < 16; ++white)
    {
      if (black <= white)
      {
	table[index(Progress16(black), Progress16(white))] =
	  -table[index(Progress16(white), Progress16(black))];
      }
    }
  }
}


osl::misc::CArray<int, 256> osl::eval::ml::ProgressAttackDefense::table;

int osl::eval::ml::ProgressAttackDefense::eval(
  Progress16 black_attack, Progress16 white_defense,
  Progress16 white_attack, Progress16 black_defense)
{
  return table[index(black_attack, white_defense)] -
    table[index(white_attack, black_defense)];
}

void osl::eval::ml::
ProgressAttackDefense::setUp(const Weights &weights)
{
  for (size_t i = 0; i < weights.dimension(); ++i)
  {
    table[i] = weights.value(i);
  }
}


osl::misc::CArray<int, 65536>
osl::eval::ml::ProgressAttackDefenseAll::table;

int osl::eval::ml::ProgressAttackDefenseAll::eval(
  Progress16 black_attack, Progress16 white_defense,
  Progress16 white_attack, Progress16 black_defense)
{
  return table[index(black_attack, white_defense,
		     white_attack, black_defense)];
}

void osl::eval::ml::
ProgressAttackDefenseAll::setUp(const Weights &weights)
{
  for (size_t i = 0; i < weights.dimension(); ++i)
  {
    table[i] = weights.value(i);
  }
  for (int ba = 0; ba < 16; ++ba)
  {
    for (int wd = 0; wd < 16; ++wd)
    {
      for (int wa = 0; wa < 16; ++wa)
      {
	for (int bd = 0; bd < 16; ++bd)
	{
	  if (ba + wd < wa + bd ||
	      (ba + wd == wa + bd &&
	       ba <= wa))
	  {
	    table[index(Progress16(ba), Progress16(wd),
			Progress16(wa), Progress16(bd))] =
	      -table[index(Progress16(wa), Progress16(bd),
			   Progress16(ba), Progress16(wd))];
	  }
	}
      }
    }
  }
}