int main(int argc, char* argv[]){ int i=0; int j=0; MazeInfo maze; if(argc<2){ printf("Usage: MapSolver <MazeFile>\n"); return 0; } if(GetMaze(argv[1], &maze) == FAIL) return 0; if(Solve(&maze) == FAIL) return 0; for(i=0; i<maze.RowSize; ++i){ for(j=0; j<maze.ColumnSize; ++j){ printf("%c", maze.Data[i][j]); } printf("\n"); } return 0; }
bool King::LookNorth() { Location temp = GetLocation(); temp.MoveY(-1); return GetLocation().IsWall(temp.GetCoordinates(), GetMaze()); };
void Test1() { int a[N][N] = { 0 }; GetMaze((int*)a, N); cout << "迷宫:" << endl; PrintMaze((int*)a, N); stack<Pos> paths; Pos entry = { 2,0 };//入口坐标 cout << "是否有通路?" << SearchMazeSize((int*)a, N, entry, paths) << endl; cout << endl; PrintMaze((int*)a, N); }
void TestMaze() { int a[n][n] = {}; GetMaze((int *)a, n); PrintMaze((int *)a, n); stack<Pos> path; Pos entry = { 2, 0 }; bool ret = MazePath((int *)a, n, entry, path); cout << "ÊÇ·ñÓÐͨ·" << ret << endl; PrintMaze((int *)a, n); }
GameStatus MyWorld::RunLevel() { //Nachman Initializations NachMan* Nach = GetNachMan(); Maze* cur_maze = GetMaze(); if (Nach->GetNumLivesLeft() > 0) { Nach->SetActorState(ALIVE, false); //This sets NachMan direction to NONE Nach->SetX(cur_maze->GetNachManStartX()); Nach->SetY(cur_maze->GetNachManStartY()); } //Monster Initializations Actor* Monst; for (int i=0;i<NUM_MONSTERS;i++) { Monst = GetMonster(i); Monst->SetActorState(NORMAL, true); Monst->SetX(cur_maze->GetMonsterStartX()); Monst->SetY(cur_maze->GetMonsterStartY()); } DisplayScreen(true); while(Nach->GetActorState() == ALIVE && cur_maze->GetRemainingFood() > 0) { Nach->doSomething(); //Allow NachMan to move //If NachMan is still alive, allow monsters to move if(Nach->GetActorState() == ALIVE) { for (int j = 0; j <NUM_MONSTERS; j++) { Monst = GetMonster(j); Monst->doSomething(); } } DisplayScreen(false); } if (cur_maze->GetRemainingFood() == 0) return FINISHED_LEVEL; else return PLAYER_DIED; }
int main(int argc, char* argv[]) { int i = 0; int j = 0; MazeInfo Maze; if (argc < 2) { printf("Usage: MazeSolver <MazeFile>\n"); return 0; } // 미로 정보 가져오기 if (GetMaze(argv[1], &Maze) == FAIL) { return 0; } // 미로를 푼다 if (Solve(&Maze) == FAIL) { return 0; } // 미로 결과 출력 for (i=0; i<Maze.RowSize; i++) { for (j =0; j<Maze.ColumnSize;j++) { printf("%c", Maze.Data[i][j]); } printf("\n"); } return 0; }