Knight's Tour Generator
Tourneys and the Fast Generation and Obfuscation of Closed Knight's Tours
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CRail Class Reference

A rail. More...

#include <Rail.h>

Public Member Functions

 CRail (int src0, int dest0, int src1, int dest1, UINT w)
 Constructor. More...
 
void GetEdge0 (int &src, int &dest)
 Get first edge. More...
 
void GetEdge1 (int &src, int &dest)
 Get second edge. More...
 

Private Member Functions

bool IsKnightMove (int i, int j)
 Knight's move test. More...
 

Private Attributes

int m_nSrc0 = UNUSED
 Index of cell at one end of first edge.
 
int m_nDest0 = UNUSED
 Index of cell at the other end of first edge.
 
int m_nSrc1 = UNUSED
 Index of cell at one end of second edge.
 
int m_nDest1 = UNUSED
 Index of cell at the other end of second edge.
 
int m_nWidth = 0
 Width of chessboard.
 

Detailed Description

A rail consists of two knight's moves in which the pair of source vertices and the pair of destination vertices are both separated by a knight's move. There are 12 types of rail, shown in the image below (the rail edges are shown in black and the knight's moves between their end points are shown in gray).

rails.png

Definition at line 41 of file Rail.h.

Constructor & Destructor Documentation

◆ CRail()

CRail::CRail ( int  src0,
int  dest0,
int  src1,
int  dest1,
UINT  w 
)

The rail constructor stores the indexes of the source and destination cells of two knight's moves in which the two source cells are separated by a knight's move and the two destination are separated by a knight's move. If the parameters fail these constraints then all four indices are set to UNUSED.

Parameters
src0Index of cell at source end of first move.
dest0Index of cell at destination end of first move.
src1Index of cell at source end of second move.
dest1Index of cell at the destination end of second move.
wBoard width.

Definition at line 45 of file Rail.cpp.

Member Function Documentation

◆ GetEdge0()

void CRail::GetEdge0 ( int &  src,
int &  dest 
)

Reader function for the first edge.

Parameters
src[out] Source vertex for the first edge.
dest[out] Source vertex for the first edge.

Definition at line 71 of file Rail.cpp.

◆ GetEdge1()

void CRail::GetEdge1 ( int &  src,
int &  dest 
)

Reader function for the second edge.

Parameters
src[out] Source vertex for the second edge.
dest[out] Source vertex for the second edge.

Definition at line 80 of file Rail.cpp.

◆ IsKnightMove()

bool CRail::IsKnightMove ( int  i,
int  j 
)
private

Test whether two cells are separated by a knight's move. Assumes that the board width m_nWidth has been set by the constructor.

Parameters
iBoard cell index.
jBoard cell index.
Returns
true if j is a knight's move from i (and vice-versa)

Definition at line 55 of file Rail.cpp.