-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathABstats.h
127 lines (89 loc) · 2.13 KB
/
ABstats.h
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
/*
DDS, a bridge double dummy solver.
Copyright (C) 2006-2014 by Bo Haglund /
2014-2018 by Bo Haglund & Soren Hein.
See LICENSE and README.
*/
#ifndef DDS_ABSTATS_H
#define DDS_ABSTATS_H
#include <iostream>
#include <fstream>
#include <string>
#include "debug.h"
using namespace std;
/*
AB_COUNT is a macro that avoids the tedious #ifdef's at
the code places to be counted.
*/
#ifdef DDS_AB_STATS
#define AB_COUNT(a, b, c) thrp->ABStats.IncrPos(a, b, c)
#else
#define AB_COUNT(a, b, c) 1
#endif
enum ABCountType
{
AB_TARGET_REACHED = 0,
AB_DEPTH_ZERO = 1,
AB_QUICKTRICKS = 2,
AB_QUICKTRICKS_2ND = 3,
AB_LATERTRICKS = 4,
AB_MAIN_LOOKUP = 5,
AB_SIDE_LOOKUP = 6,
AB_MOVE_LOOP = 7,
AB_SIZE = 8
};
#define DDS_MAXDEPTH 49
struct ABtracker
{
int list[DDS_MAXDEPTH];
int sum;
int sumWeighted;
int sumCum;
int sumCumWeighted;
};
class ABstats
{
private:
string name[AB_SIZE];
// A node arises when a new move is generated.
// Not every move leads to an AB termination.
ABtracker ABnodes;
ABtracker ABnodesCum;
// AB terminations are tracked by side and position.
ABtracker ABsides[2];
ABtracker ABplaces[AB_SIZE];
void SetNames();
void PrintHeaderPosition(ofstream& fout) const;
void PrintStatsPosition(
ofstream& fout,
const int no,
const string& text,
const ABtracker& abt,
const ABtracker& divisor) const;
void PrintHeaderDepth(ofstream& fout) const;
void PrintStatsDepth(
ofstream& fout,
const int depth,
const int cum) const;
void PrintAverageDepth(
ofstream& fout,
const ABtracker& ABsidesSum) const;
void PrintHeaderDetail(ofstream& fout) const;
void PrintStatsDetail(
ofstream& fout,
const int depth) const;
void PrintSumDetail(ofstream& fout) const;
public:
ABstats();
~ABstats() = default;
void Reset();
void ResetCum();
void IncrPos(
const ABCountType no,
const bool side,
const int depth);
void IncrNode(const int depth);
int GetNodes() const;
void PrintStats(ofstream& fout);
};
#endif