|
迷宫求解的过程演示(1)
前些日子,帮一个朋友做了个作业,是关于迷宫求解的演示 迷宫求解是个很经典的问题,这个我想不是讨论的问题 我想让大家看看我的思路,提提意见 下面是程序 //头文件 #ifndef Labyrinth_StrUCtH #define Labyrinth_StructH #include <vcl.h> #pragma hdrstop typedef void __fastcall (__closure *TMyEvent)(int ID); const int EVENT_PAINT=0; const int EVENT_BACKDATE=1; const int EVENT_OK=3; const int STATE_ERROR=-1; const int STATE_PASS=0;//可以通过 const int STATE_PASSED=1; //标记已经通过 const int STATE_CANNOTPASS=2;//不能通过 const int STATE_ENTRY=3; //入口点 const int STATE_END=4; //出口点 class SPoint { public: __fastcall ~SPoint() { } __fastcall SPoint() { PriorityDirection=1; Count=-1; } __fastcall SPoint(TPoint tPoint) { PriorityDirection=1; Count=-1; X=tPoint.x; Y=tPoint.y; } __fastcall SPoint(int tX,int tY) { PriorityDirection=1; Count=-1; X=tX; Y=tY; } int operator==(const SPoint& Source) { return(Source.X==X&&Source.Y==Y); } int operator!=(const SPoint& Source) { return(Source.X!=XSource.Y!=Y); } int X; int Y; int Count; int PriorityDirection;//一个优先方向另加四个方向 }; template<class T>class CShed //栈 { public: TList *List; __fastcall CShed(); __fastcall ~CShed(); T *Pop(); void Push(T *point);
}; class CLabyrinth { TCanvas *LabyrinthCanvas; int ImageHeight;
|