45 m_nWidth(w), m_nHeight(h), m_nSize(w*h){
57 #pragma region Task::Generate 72 if(gentype == GeneratorType::DivideAndConquer){
83 else if(gentype == GeneratorType::ConcentricBraid){
94 else if(gentype == GeneratorType::FourCover){
108 for(
int i=0; i<nThreads; i++)
111 for(
int i=0; i<nThreads; i++)
123 std::mem_fn(&std::thread::join));
135 printf(
"\n**** Error: Search failed, nothing to print.\n");
149 #pragma endregion generation task 154 #pragma region Task::Measure 168 for(
int i=0; i<n; i++){
183 for(
int i=0; i<nThreads; i++)
189 std::mem_fn(&std::thread::join));
198 std::vector<CSearchResult> results;
203 results.push_back(r);
207 double fSingleMove[8] = {0};
208 double fRelativeMove[8] = {0};
210 double fSingleMean[8] = {0};
211 double fRelativeMean[8] = {0};
213 double fSingleStdev[8] = {0};
214 double fRelativeStdev[8] = {0};
219 for(
int i=0; i<8; i++){
224 for(
int i=0; i<8; i++){
225 fSingleMove[i] /= (double)
m_nSize;
226 fRelativeMove[i] /= (double)
m_nSize;
231 for(
int i=0; i<8; i++){
232 fSingleMean[i] = fSingleMove[i]/(double)n;
233 fRelativeMean[i] = fRelativeMove[i]/(double)n;
238 const double denom = (double)
m_nSize;
241 for(
int i=0; i<8; i++){
248 const double denom = (double)n - 1;
250 for(
int i=0; i<8; i++){
251 fSingleStdev[i] = sqrt(fSingleStdev[i]/denom);
252 fRelativeStdev[i] = sqrt(fRelativeStdev[i]/denom);
259 +
"-" + std::to_string(n) +
".txt";
261 FILE* output = fopen(strFileName.c_str(),
"wt");
263 if(output !=
nullptr){
264 fprintf(output,
"Single\n");
265 fprintf(output,
"Mean\t");
OutputStat(output, fSingleMean);
266 fprintf(output,
"Stdev\t");
OutputStat(output, fSingleStdev);
267 fprintf(output,
"\n");
269 fprintf(output,
"Relative\n");
270 fprintf(output,
"Mean\t");
OutputStat(output, fRelativeMean);
271 fprintf(output,
"Stdev\t");
OutputStat(output, fRelativeStdev);
284 fprintf(output,
"%0.4f", a[0]);
285 for(
int i=1; i<8; i++)
286 fprintf(output,
"\t%0.4f", a[i]);
287 fprintf(output,
"\n");
290 #pragma endregion Task::Measure 295 #pragma region Task::Time 308 for(
int i=0; i<n; i++){
321 for(
int i=0; i<nThreads; i++)
327 std::mem_fn(&std::thread::join));
334 strFileName +=
"-" + std::to_string(n) +
".txt";
336 FILE* output = fopen(strFileName.c_str(),
"at");
338 if(output !=
nullptr){
354 if(output !=
nullptr)
355 fprintf(output,
"%d\t%0.2f\t%0.2f\n",
m_nWidth, fCpu, fElapsed);
358 #pragma endregion Task::Time void OutputTimes(FILE *output, float fCpu, float fElapsed)
Output times.
Header for the concentric braided tourney generator CConcentricBraid.
const char * GetCurrentDateAndTime()
Get current time and date.
void Generate(CBoard &b)
Generate a concentric braided tourney.
Four-cover tourney generator.
Defines, enumerated types, and typedefs.
CGenerator()
Default constructor.
Header for the divide-and conquer generator CDivideAndConquer.
void Generate(CBoard &b, CycleType t, const CRect &rect)
Recursion.
void Time(const CTourneyDesc &t, int nThreads, int n)
Time.
void OutputStat(FILE *output, double a[8])
Output a statistic.
void Start()
Start timing.
void push(const data &element)
Insert at tail.
Timer for elapsed time and CPU time.
void Generate(const CTourneyDesc &t, int nThreads)
Generate.
Header for the tourney and knight's tour generator CGenerator.
Header for the four-cover tourney generator CFourCover.
void Generate(CBoard &b)
Generate a four-cover tourney.
void JoinUntilTour()
Join cycles to reduce tourney size.
UINT64 m_nRelativeMove[8]
Double move count.
static CThreadSafeQueue< CSearchResult > m_cSearchResult
Search result queue.
#define sqr(x)
Squaring function.
Header for the timer CTimer.
size_t size()
Get queue size.
float GetCPUTime()
Get CPU time in seconds.
void Finish()
Print CPU and elapsed time.
bool m_bDiscard
Discard result.
std::vector< std::thread > m_vecThreadList
Thread list for search.
GeneratorType
Generator type.
bool pop(data &element)
Delete from head and return.
Concentric braided tourney generator.
CBoard * m_pBoard
Pointer to chessboard.
GeneratorType m_eGenerator
Generator type.
void Save(std::string &name)
Save board to a text file.
float GetElapsedTime()
Get elapsed time in seconds.
Header for the pseudo-random number generator CRandom.
Header for the chessboard CBoard.
CycleType m_eCycle
Cycle type.
Knight's tour and tourney generator.
int m_nHeight
Board height.
Divide-and-conquer knight's tour and tourney generator.
UINT64 m_nSingleMove[8]
Single move count.
std::string MakeFileNameBase(const CTourneyDesc &t, int w)
Make file name base.
void Obfuscate()
Obfuscate function.
void Measure(const CTourneyDesc &t, int nThreads, int n)
Measure.
CTourneyDesc m_cTourneyDesc
Tourney descriptor.
void SaveToSVG(std::string &name)
Save to an SVG file.
static CThreadSafeQueue< CSearchRequest > m_cSearchRequest
Search request queue.
bool m_bObfuscate
Whether to obfuscate.