/* maze.c graph.h, maze.h を同じディレクトリに download して用いよ maze.h は使用環境に合わせて漢字コードを変換して用いよ コンパイル命令と実行命令: gcc maze.c -o maze ./maze K. Shiota 2005.5.31-6.6 2005.6.9 version */ #include #include #define MAXORDER 256 #define MAXMAZESIZE 16 #include "graph.h" #include "maze.h" main() { Maze m; Graph tree; // 探索木 List parent; // 親を登録するリスト List path={0,{}}; // 道順(初期値は空) int startNode; // 出発点 int goalNode; // 目的地 int i; srand(time(NULL)); m=GenerateMaze(16,16); WriteMaze(m); startNode=0; // 出発点は西北端 goalNode=m.g.ord-1; // 目的地は南東端 tree=WFSTree(m.g,startNode,&parent); if(parent.mem[goalNode]!=-1){ // goalNode に親がいれば道あり // goalNode から順に親をたどって道順 path を作る path=ParentPath(parent,startNode,goalNode); printf("\nHit Any Key"); getchar(); printf("\nSolution : \n"); for(i=0;i "); printf("(%d,%d)",path.mem[i]/m.col,path.mem[i]%m.col); } printf("\n\n"); WriteMazePath(m,path); } }