[go: up one dir, main page]

Menu

[r1]: / trunk / rlgomain / RlCommands.h  Maximize  Restore  History

Download this file

151 lines (121 with data), 3.9 kB

  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
148
149
150
//----------------------------------------------------------------------------
/** @file RlCommands.h
GTP extension commands for RLGO
*/
//----------------------------------------------------------------------------
#ifndef RLCOMMANDS_H
#define RLCOMMANDS_H
#include "GtpEngine.h"
#include "RlActiveSet.h"
#include "RlUtils.h"
#include <vector>
class GtpCommand;
class GtpEngine;
class RlRealAgent;
class RlSetup;
class RlTracker;
class RlWeightSet;
//----------------------------------------------------------------------------
/** GTP extension commands for RLGO */
class RlCommands
{
public:
RlCommands();
void Setup(RlSetup* setup);
void Register(GtpEngine& e);
void AddGoGuiAnalyzeCommands(GtpCommand&);
/** @name Command Callbacks */
// @{
void CmdActiveAll(GtpCommand&);
void CmdActiveNext(GtpCommand&);
void CmdActivePrev(GtpCommand&);
void CmdActiveWeights(GtpCommand&);
void CmdDirty(GtpCommand&);
void CmdEvalParams(GtpCommand& cmd);
void CmdEvaluate(GtpCommand&);
void CmdFeatureNext(GtpCommand&);
void CmdFeaturePrev(GtpCommand&);
void CmdLicense(GtpCommand&);
void CmdLoadWeights(GtpCommand&);
void CmdMoveFilter(GtpCommand&);
void CmdMoveFreqs(GtpCommand&);
void CmdNewGame(GtpCommand&);
void CmdOutputParams(GtpCommand& cmd);
void CmdPageNext(GtpCommand&);
void CmdPagePrev(GtpCommand&);
void CmdPolicy(GtpCommand&);
void CmdSaveWeights(GtpCommand&);
void CmdSimulate(GtpCommand&);
void CmdTopTex(GtpCommand&);
void CmdVariation(GtpCommand&);
// @} // @name
void WriteFloatBoard(GtpCommand& cmd, const std::vector<RlFloat>& v);
void WriteStringBoard(GtpCommand& cmd, const std::vector<std::string>& v);
protected:
void Register(GtpEngine& engine, const std::string& command,
GtpCallback<RlCommands>::Method method);
void AllActive(std::vector<RlChange>& entries);
void DescribeActive(GtpCommand& cmd, RlChange& entry, int size);
void DescribeFeature(GtpCommand& cmd, int m_featureIndex);
void DescribePage(GtpCommand& cmd);
class Influence
{
public:
Influence();
RlFloat Value(SgPoint pt) const { return m_values[pt]; }
bool IsSet(SgPoint pt) { return m_set[pt]; }
void Set(SgPoint pt, RlFloat value);
void Add(SgPoint pt, RlFloat value);
void DBoard(RlCommands* commands, GtpCommand& cmd);
void Gfx(RlCommands* commands, GtpCommand& cmd);
private:
RlFloat m_values[SG_MAXPOINT];
bool m_set[SG_MAXPOINT];
};
struct Scale
{
Scale()
: m_mode(RL_NONE) { }
RlFloat ScaleFloat(RlFloat eval) const;
void ScaleInfluence(RlCommands::Influence& influence) const;
std::string ModeString(int mode) const;
enum
{
RL_NONE,
RL_CENTRED,
RL_LOGISTIC,
RL_LINEAR,
RL_STDDEV,
RL_MAXDEV,
RL_NUM_MODES
};
int m_mode;
RlFloat m_min, m_max;
};
//@todo: make these const access
GoBoard& Board() { return *m_board; }
RlRealAgent* Agent() { return m_agent; }
private:
class EntryCmp
{
public:
EntryCmp(const RlWeightSet* weightset)
: m_weightSet(weightset)
{ }
bool operator()(const RlChange& lhs, const RlChange& rhs) const;
private:
const RlWeightSet* m_weightSet;
};
GoBoard* m_board;
RlRealAgent* m_agent;
// State required by GTP commands
bool m_stepSize;
bool m_sort;
int m_numPV;
int m_featureIndex;
int m_activeIndex;
int m_pageIndex;
Scale m_scale;
};
//----------------------------------------------------------------------------
#endif // RLCOMMANDS_H