/usr/include/osl/eval/evalTraits.h is in libosl-dev 0.6.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | /* evalTraits.h
*/
#ifndef _EVAL_TRAITS_H
#define _EVAL_TRAITS_H
#include "osl/player.h"
#include <algorithm>
namespace osl
{
namespace eval
{
template<Player P>
struct EvalTraits;
template<>
struct EvalTraits<BLACK>
{
static const int delta=1;
static const int MAX_VALUE = 250000000;
// infty become specific to Evaluation class
static int max(int v1,int v2){ return std::max(v1,v2); }
static int min(int v1,int v2){ return std::min(v1,v2); }
static bool betterThan(int v1,int v2)
{
return v1 > v2;
}
static bool notLessThan(int v1,int v2) {
return v1 >= v2;
}
/**
* @param value BLACKのための値
*/
static int convert(int value)
{
assert(value >= 0);
return value;
}
};
template<>
struct EvalTraits<WHITE>
{
static const int delta= -EvalTraits<BLACK>::delta;
static const int MAX_VALUE= -EvalTraits<BLACK>::MAX_VALUE;
static int max(int v1,int v2){ return std::min(v1,v2); }
static int min(int v1,int v2){ return std::max(v1,v2); }
static bool betterThan(int v1,int v2)
{
return v1 < v2;
}
static bool notLessThan(int v1,int v2)
{
return v1 <= v2;
}
/**
* @param value BLACKのための値
*/
static int convert(int value)
{
assert(value >= 0);
return -value;
}
};
inline bool betterThan(Player p, int v1,int v2)
{
assert(isValid(p));
if (p == BLACK)
return EvalTraits<BLACK>::betterThan(v1,v2);
else
return EvalTraits<WHITE>::betterThan(v1,v2);
}
inline bool notLessThan(Player p, int v1,int v2)
{
assert(isValid(p));
if (p == BLACK)
return EvalTraits<BLACK>::notLessThan(v1,v2);
else
return EvalTraits<WHITE>::notLessThan(v1,v2);
}
inline int max(Player p, int v1, int v2)
{
assert(isValid(p));
if (p == BLACK)
return EvalTraits<BLACK>::max(v1,v2);
else
return EvalTraits<WHITE>::max(v1,v2);
}
inline int min(Player p, int v1, int v2)
{
assert(isValid(p));
if (p == BLACK)
return EvalTraits<BLACK>::min(v1,v2);
else
return EvalTraits<WHITE>::min(v1,v2);
}
/**
* playerにとってちょっと高い値
*/
inline int delta(Player p)
{
assert(isValid(p));
if (p == BLACK)
return EvalTraits<BLACK>::delta;
else
return EvalTraits<WHITE>::delta;
}
/**
* @param value BLACKのための値
*/
inline int convert(Player P, int value)
{
assert(value >= 0);
return value*delta(P);
}
/**
* 詰がからんでいない局面での通常の評価値
*/
template <class Eval>
inline bool isConsistentValueForNormalState(int value)
{
const int infty = Eval::infty();
return ((value % 2) == 0)
&& EvalTraits<BLACK>::betterThan(value, EvalTraits<WHITE>::convert(infty))
&& EvalTraits<WHITE>::betterThan(value, infty);
}
inline bool isConsistentValue(int value)
{
return (value % 2) == 0
&& (EvalTraits<BLACK>::MAX_VALUE >= value)
&& (EvalTraits<WHITE>::MAX_VALUE <= value);
}
} // namespace eval
using eval::EvalTraits;
} // namespace osl
#endif /* _EVAL_TRAITS_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
|