![]() |
Knight's Tour Generator
Tourneys and the Fast Generation and Obfuscation of Closed Knight's Tours
|
Knight's tour and tourney generator. More...
#include <Generator.h>
Public Member Functions | |
CGenerator (int w, int h) | |
Constructor. More... | |
CGenerator (int n) | |
Constructor. More... | |
CGenerator () | |
Default constructor. More... | |
void | Generate (const CTourneyDesc &t, int nThreads) |
Generate. More... | |
void | Measure (const CTourneyDesc &t, int nThreads, int n) |
Measure. More... | |
void | Time (const CTourneyDesc &t, int nThreads, int n) |
Time. More... | |
Private Member Functions | |
void | OutputStat (FILE *output, double a[8]) |
Output a statistic. More... | |
void | OutputTimes (FILE *output, float fCpu, float fElapsed) |
Output times. More... | |
Private Attributes | |
std::vector< std::thread > | m_vecThreadList |
Thread list for search. | |
int | m_nWidth = 0 |
Board width. | |
int | m_nHeight = 0 |
Board height. | |
int | m_nSize = 0 |
Board size. | |
Additional Inherited Members | |
![]() | |
static CThreadSafeQueue< CSearchRequest > | m_cSearchRequest |
Search request queue. | |
static CThreadSafeQueue< CSearchResult > | m_cSearchResult |
Search result queue. | |
The generator constructs tourneys and knight's tours. Those that use randomized algorithms are multi-threaded. The resulting tourneys and knight's tours can either be output (single tourneys and knight's tours only), or the generation of large numbers of them can be timed, or various statistics can be measured.
Definition at line 47 of file Generator.h.
CGenerator::CGenerator | ( | int | w, |
int | h | ||
) |
Create an empty rectangular chessboard.
w | Board width. |
h | Board width. |
Definition at line 44 of file Generator.cpp.
CGenerator::CGenerator | ( | int | n | ) |
Create an empty square chessboard.
n | Width and height of a square chessboard. |
Definition at line 51 of file Generator.cpp.
CGenerator::CGenerator | ( | ) |
Create a very empty chessboard.
Definition at line 37 of file Generator.cpp.
void CGenerator::Generate | ( | const CTourneyDesc & | t, |
int | nThreads | ||
) |
Generate a single knight's tour or tourney. Fill the request queue, launch the search threads, then wait for them to terminate and output the resulting tour or tourney to a file.
t | Tourney descriptor. |
nThreads | Number of search threads to use. |
Definition at line 66 of file Generator.cpp.
void CGenerator::Measure | ( | const CTourneyDesc & | t, |
int | nThreads, | ||
int | n | ||
) |
Measure statistics on multiple knight's tours or tourneys. Fill the request queue, launch the search threads, then wait for them to terminate. Count the number of occurrences of the 8 single moves and 8 double moves possible and write the results to a text file.
t | Type of tour to generate. |
nThreads | Number of search threads to use. |
n | Number of tours to generate. |
Definition at line 165 of file Generator.cpp.
|
private |
Output statistic from the generation multiple knight's tours or tourneys to a file.
output | File pointer. |
a | Array of 8 numbers. |
Definition at line 282 of file Generator.cpp.
|
private |
Append times (cpu time and elapsed time) from the generation of multiple knight's tours or tourneys to a text file. The file name contains the tourney type.
output | Pointer to file. |
fCpu | CPU time in seconds. |
fElapsed | Elapsed time in seconds. |
Definition at line 351 of file Generator.cpp.
void CGenerator::Time | ( | const CTourneyDesc & | t, |
int | nThreads, | ||
int | n | ||
) |
Report the CPU and elapsed time required to generate multiple knight's tours or tourneys. Fill the request queue, launch the search threads, wait for them to terminate, then append the CPU and elapsed times to a text file.
t | Tourney descriptor. |
nThreads | Number of search threads to use. |
n | Number of tours to generate. |
Definition at line 305 of file Generator.cpp.