[go: up one dir, main page]

Menu

[r74]: / trunk / rlgo / RlTracker.h  Maximize  Restore  History

Download this file

90 lines (63 with data), 2.5 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
//----------------------------------------------------------------------------
/** @file RlTracker.h
Base class for incrementally tracking changes to active set
*/
//----------------------------------------------------------------------------
#ifndef RLTRACKER_H
#define RLTRACKER_H
#include "RlActiveSet.h"
#include "RlUtils.h"
class RlDirtySet;
class RlMoveFilter;
//----------------------------------------------------------------------------
/** Base class for incrementally tracking active set of binary features */
class RlTracker
{
public:
RlTracker(GoBoard& board);
virtual ~RlTracker() { }
/** Initialise tracker after (multi-stage) construction is complete */
virtual void Initialise();
/** Reset evaluation and features to current board position */
virtual void Reset() = 0;
/** Update features from this move
Called after board is updated */
virtual void Execute(SgMove move, SgBlackWhite colour,
bool execute, bool store) = 0;
/** Update features from undo
Called after board is updated */
virtual void Undo() = 0;
/** Update dirty points for specified move */
virtual void UpdateDirty(SgMove move, SgBlackWhite colour,
RlDirtySet& dirty);
/** Size of active set */
virtual int GetActiveSize() const = 0;
/** Debug output */
virtual void Display(std::ostream& ostr) { SG_UNUSED(ostr); }
/** Current list of changes (after Reset, Execute or Undo) */
const RlChangeList& ChangeList() const { return m_changeList; }
/** Remember current position for fast resets */
virtual void SetMark() { m_mark = true; }
virtual void ClearMark() { m_mark = false; }
bool MarkSet() const { return m_mark; }
protected:
void ClearChanges() { m_changeList.Clear(); }
void NewChange(int slot, int featureindex, RlOccur occurrences);
void MarkAtarisDirty(SgMove move, SgBlackWhite colour);
void MarkAllDirty();
protected:
GoBoard& m_board; //@todo: constify
private:
/** Mark is set if data has been stored for fast reset */
bool m_mark;
/** Current set of changes for this tracker
Use to update active features by calling AddChanges */
RlChangeList m_changeList;
};
inline void RlTracker::NewChange(int slot, int featureindex,
RlOccur occurrences)
{
m_changeList.Change(RlChange(slot, featureindex, occurrences));
}
//----------------------------------------------------------------------------
#endif // RLTRACKER_H