迷宫算法确实很给人吸引力,但若是结合图形化的显示,相信形式化思维的你对此会感到顿时脑洞大开,在此希望大家进行评论或者提出意见
//每个迷宫位置的抽象
struct Items{
char post_x;//杭位置
char post_y;//列位置
char dir;//方向
};
//基于方向的偏移确定
struct offsets{
char x;//x偏移
char y;//y偏移
};
enum direction{N,NE,E,SE,S,SW,W,NW};//方向表示
struct offsets moves[8];//八个方向的偏移数组
//迷宫模拟,可找算法生成
char maze[MAZE_SIZE-1][MAZE_SIZE+2]={
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,1,0,0,0,1,1,0,0,0,1,1,1,1,1,1},
{1,1,0,0,0,0,1,0,1,1,1,0,0,1,1,1,1},
{1,0,1,1,0,0,0,0,1,1,1,1,0,0,1,1,1},
{1,1,1,0,1,1,1,1,0,1,1,0,1,1,0,0,1},
{1,1,1,0,1,0,0,1,0,1,1,1,1,1,1,1,1},
{1,0,0,1,1,0,1,1,1,0,1,0,0,1,0,1,1},
{1,0,0,1,1,0,1,1,1,0,1,0,0,1,0,1,1},
{1,0,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1},
{1,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1,1},
{1,1,1,0,0,0,1,1,0,1,1,0,0,0,0,0,1},
{1,0,0,1,1,1,1,1,0,0,0,1,1,1,1,0,1},
{1,0,1,0,0,1,1,1,1,1,0,1,1,1,1,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
};
//迷宫访问位置屏蔽位,默认为0,既没有访问过
char mark[MAZE_SIZE-1][MAZE_SIZE+2]={
{0}
};
moves[0].x = -1;moves[0].y = 0;
void main()
{
printf("hello maze\n");
cout<<"init the direction vector"<<endl;
//基于方向偏移的初始化
moves[0].x = -1;moves[0].y = 0;
moves[1].x = -1;moves[1].y = 1;
moves[2].x = 0;moves[2].y = 1;
moves[3].x = 1;moves[3].y = 1;
moves[4].x = 1;moves[4].y = 0;
moves[5].x = 1;moves[5].y = -1;
moves[6].x = 0;moves[6].y = -1;
moves[7].x = -1;moves[7].y = -1;
/*