75 return IsRail(s0, d0, s1, d1);
144 for(
int s0=0; s0<(int)
m_nSize; s0++)
149 for(
int j=4; j<8; j++)
155 if(
IsRail(s0, d0, s1, d1))
163 const int n = (int)rails.size();
165 for(
int i=0; i<n; i++)
202 std::vector<CRail> rails;
217 for(
int i=0; i<16; i++)
240 std::vector<CRail> rails;
247 if(numcycles == 1)
return true;
251 bool* used =
new bool[
m_nSize];
258 std::vector<UINT> vecEdgeToRail;
261 int src0, dest0, src1, dest1;
263 r.GetEdge0(src0, dest0);
264 r.GetEdge1(src1, dest1);
266 if(!used[src0] && !used[dest0] && !used[src1] && !used[dest1]){
267 const int idsrc0 =
id[src0];
268 const int iddest0 =
id[dest0];
270 const int idsrc1 =
id[src1];
271 const int iddest1 =
id[dest1];
273 if(idsrc0 == iddest0 && idsrc1 == iddest1 && idsrc0 != idsrc1){
276 used[src0] = used[src1] = used[dest0] = used[dest1] =
true;
277 vecEdgeToRail.push_back(count);
291 std::vector<UINT> spanningforest;
292 const UINT numtrees = g.
BFSF(spanningforest);
294 for(
UINT i: spanningforest){
295 UINT j = vecEdgeToRail[i];
299 return numtrees == 1;
310 bool bWasUndirected =
false;
313 bWasUndirected =
true;
321 }
while(numcycles > 1);
bool InsertDirectedMove(int src, int dest)
Insert a directed move.
int GetMoveIndex(int src, int dest)
Get move index.
void Shatter()
Shatter tourneys into more tourneys.
Defines, enumerated types, and typedefs.
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.
bool Join()
Join cycles to reduce tourney size.
bool IsUndirected()
Undirected board test.
UINT randn()
Get a random unsigned integer.
UINT m_nSize
Board size in cells.
bool IsRail(int s0, int d0, int s1, int d1)
Rail test.
bool IsKnightMove(int i, int j)
Knight's move test.
int * m_nMove2
Secondary move table.
void GetEdge0(int &src, int &dest)
Get first edge.
MoveDeltas g_vecDeltas
Move deltas for all possible knight's moves.
void JoinUntilTour()
Join cycles to reduce tourney size.
unsigned int UINT
Abbreviation for unsigned integer.
void InsertEdge(const UINT i, const UINT j)
Insert an edge.
void GetEdge1(int &src, int &dest)
Get second edge.
#define UNUSED
Contents of unused square on the chessboard.
UINT BFSF(std::vector< UINT > &result)
Breadth-first spanning forest.
Header for the graph CGraph and its vertices CVertex and edges CEdge.
bool IsMove(int i, int j)
Move test.
int * m_nMove
Primary move table.
void Switch(CRail &r)
Switch a rail.
Header for the chessboard CBoard.
bool IsTour()
Knight's tour test.
std::vector< MoveDelta > MoveDeltas
Move deltas for knight's moves.
void FindRails(std::vector< CRail > &rails)
Find all rails.
void MakeUndirected()
Make into an undirected board.
void Obfuscate()
Obfuscate function.
UINT m_nWidth
Board width in cells.