50   m_nWidth(w), m_nHeight(h), m_nSize(w*h)
    69   m_nWidth(w), m_nHeight(h), m_nSize(w*h)
   103   return 0 <= index && index < (int)
m_nSize;
   141   if(0 <= i && i < n && 0 <= j && j < n) 
   144         const int x = i%
m_nWidth + delta.first;
   145         const int y = i/
m_nWidth + delta.second;
   178   const int x = pos%
m_nWidth + d.first; 
   179   const int y = pos/
m_nWidth + d.second; 
   193   const int x = pos%
m_nWidth + d.first; 
   194   const int y = pos/
m_nWidth + d.second; 
   214     const int x = x0 + delta.first; 
   215     const int y = y0 + delta.second; 
   248     const int dest0 = 
m_nMove[cur];
   249     const int newprev = cur;
   262   return count == 
m_nSize && cur == 0;
   276   bool bAllCellsUsed = 
true;
   284       else bAllCellsUsed = 
false;
   292       else bAllCellsUsed = 
false;
   296       else bAllCellsUsed = 
false;
   300   if(!bAllCellsUsed)
return false;
   304   bool bDegree2 = 
true;
   359       if(temp[start] == 
UNUSED){
   414       if(dy == -1)
return 3;
   415       else if(dy == 1)
return 4;
   419       if(dy == -2)
return 2;
   420       else if(dy == 2)
return 5;
   424       if(dy == -2)
return 1;
   425       else if(dy == 2)
return 6;
   429       if(dy == -1)
return 0;
   430       else if(dy == 1)
return 7;
   449   for(
int bsrcy=0; bsrcy<h; bsrcy++)
   450     for(
int bsrcx=0; bsrcx<w; bsrcx++){
   451       const int bsrc = bsrcy*w + bsrcx;
   452       const int bdest = b[bsrc];
   454       const int bdestx = bdest%w;
   455       const int bdesty = bdest/w;
   457       const int srcx = bsrcx + x0;
   458       const int srcy = bsrcy + y0;
   460       const int destx = bdestx + x0;
   461       const int desty = bdesty + y0;
   463       const int src = srcy*
m_nWidth + srcx;
   464       const int dest = desty*
m_nWidth + destx;
   475 #pragma region Move insertion and deletion   553 #pragma endregion Move insertion and deletion   558 #pragma region Save functions   575   sprintf_s(buffer, 
"%s.txt", name.c_str());
   577   FILE* output = 
nullptr;
   578   fopen_s(&output, buffer, 
"wt");
   580   if(output != 
nullptr){
   607       id[start] = numcycles; 
   615         const int dest0 = 
m_nMove[cur]; 
   648   sprintf_s(buffer, 
"%s.svg", name.c_str());
   650   FILE* output = 
nullptr;
   651   fopen_s(&output, buffer, 
"wt");
   653   if(output != 
nullptr){
   658     const float cellsize = 16; 
   659     const float spotsize = 2.8f; 
   660     const float strokewidth = 1.0f; 
   661     const float strokewidth2 = 2.0f; 
   663     const UINT sw = (
UINT)std::ceil(w*cellsize); 
   664     const UINT sh = (
UINT)std::ceil(h*cellsize); 
   666     fprintf(output, 
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); 
   670     fprintf(output, 
"<svg width=\"%u\" height=\"%u\" ", sw + 8, sh + 8);
   671     fprintf(output, 
"viewBox=\"-4 -4 %u %u\" ", sw + 8, sh + 8);
   672     fprintf(output, 
"xmlns=\"http://www.w3.org/2000/svg\">");
   676     fprintf(output, 
"<style>");
   677     fprintf(output, 
"circle{fill:black;r:%0.1f}", spotsize);
   678     fprintf(output, 
"polyline{fill:none;stroke:black;stroke-width:%0.1f}",
   680     fprintf(output, 
"line{stroke:black;stroke-width:%0.1f}", strokewidth2);
   681     fprintf(output, 
"</style>");
   685     fprintf(output, 
"<rect width=\"%u\" height=\"%u\" ", sw, sh); 
   686     fprintf(output, 
"style=\"fill:white;stroke:black;stroke-width:%s\"/>",
   691     const std::string bds = 
   692       "style=\"stroke-width:" + 
NumString(strokewidth) + 
"\"";
   693     const std::string wstr = 
NumString(w*cellsize);
   694     const std::string hstr = 
NumString(h*cellsize);
   696     for(
int i=1; i<h; i++){ 
   697       const std::string s = 
NumString((
float)i*cellsize);
   698       fprintf(output, 
"<line x1=\"0\" y1=\"%s\" x2=\"%s\" y2=\"%s\" %s/>",
   699         s.c_str(), wstr.c_str(), s.c_str(), bds.c_str());
   702     for(
int i=1; i<w; i++){ 
   703       const std::string s = 
NumString((
float)i*cellsize);
   704       fprintf(output, 
"<line x1=\"%s\" y1=\"0\" x2=\"%s\" y2=\"%s\" %s/>",
   705         s.c_str(), s.c_str(), hstr.c_str(), bds.c_str());
   710     bool* used = 
new bool[n]; 
   712     for(
int i=0; i<n; i++) 
   718     for(
int start=0; start<n; start++) 
   720         std::string polylinetag; 
   724         UINT rgb[3] = {0, 0, 0}; 
   726         const std::string colorstr = 
"rgb(" + std::to_string(rgb[0]) + 
","   727           + std::to_string(rgb[1]) + 
"," + std::to_string(rgb[2]) + 
")";
   732           polylinetag += 
"style=\"stroke:" + colorstr + 
"\" ";
   738         polylinetag += 
"points=\""; 
   743           const float x = (cur%w + 0.5f)*cellsize; 
   744           const float y = (cur/w + 0.5f)*cellsize; 
   748           std::string circletag; 
   751             circletag += 
"style=\"fill:" + colorstr + 
"\" ";           
   754           fprintf(output, 
"<circle %s/>", circletag.c_str());
   762         }
while(cur != start); 
   766         const float x = (start%w + 0.5f)*cellsize;
   767         const float y = (start/w + 0.5f)*cellsize;
   772         fprintf(output, 
"<polyline %s\"/>", polylinetag.c_str());
   775     fprintf(output, 
"</svg>\n"); 
   786 #pragma endregion Save functions bool InsertDirectedMove(int src, int dest)
Insert a directed move.
 
int GetHeight()
Get height.
 
MoveDeltas g_vecDeltas
Move deltas for all possible knight's moves.
 
int GetMoveIndex(int src, int dest)
Get move index.
 
bool IsUnused(int index)
Test for unused cell.
 
Defines, enumerated types, and typedefs.
 
bool CellIndexInRange(int index)
Index in range test.
 
bool DeleteMove(int src, int dest)
Delete a move.
 
bool IsDirected()
Directed board test.
 
UINT GetTourneyIds(int *&id)
Get tourney identifier for each cell.
 
int GetDest(int i, const MoveDelta &delta)
Get destination of move.
 
void MakeDirected()
Make into a directed board.
 
#define fprintf_s
fprintf_s for *NIX.
 
bool IsUndirected()
Undirected board test.
 
#define sprintf_s
sprintf_s for *NIX.
 
UINT m_nSize
Board size in cells.
 
std::pair< int, int > MoveDelta
Move delta for a knight's move.
 
bool IsKnightMove(int i, int j)
Knight's move test.
 
Header for helper functions.
 
int * m_nMove2
Secondary move table.
 
bool IsOnBoard(int pos, const MoveDelta &delta)
Move stays on board.
 
std::string NumString(float x)
Make string from number.
 
void randclr(UINT rgb[3])
Get a random color.
 
unsigned int UINT
Abbreviation for unsigned integer.
 
Header for the base chessboard CBaseBoard.
 
#define UNUSED
Contents of unused square on the chessboard.
 
bool InRangeY(int y)
Y coordinate in range test.
 
void Save(std::string &name)
Save board to a text file.
 
bool IsTourney()
Tourney test.
 
int GetAvailableMoveCount(int index)
Get number of moves from a cell.
 
bool IsMove(int i, int j)
Move test.
 
int * m_nMove
Primary move table.
 
void fopen_s(FILE **stream, const char *name, const char *fmt)
fopen_s for *NIX.
 
UINT m_nHeight
Board height in cells.
 
void CopyToSubBoard(CBaseBoard &b, int x, int y)
Copy to sub-board.
 
void srand()
Seed the random number generator.
 
int operator[](int index)
Get a move from the board.
 
bool IsTour()
Knight's tour test.
 
std::vector< MoveDelta > MoveDeltas
Move deltas for knight's moves.
 
void MakeUndirected()
Make into an undirected board.
 
void SaveToSVG(std::string &name)
Save to an SVG file.
 
UINT m_nWidth
Board width in cells.
 
bool InsertUndirectedMove(int src, int dest)
Insert an undirected move.
 
UINT timeGetTime()
Something a little bit like timeGetTime for *NIX.
 
void Clear()
Clear the board of moves.
 
bool InRangeX(int x)
X coordinate in range test.