bool Maze::checkAnyVis() { if (checkVisited(left)==1&&checkVisited(right)==1&&checkVisited(up)==1&&checkVisited(down)==1) { return 1; } else { return 0; } }
void Maze::nextStep() { do { visited[xpos][ypos]=1; direction dir=(direction)(rand()%4); if (checkAnyVis()==0) { while (checkVisited(dir)==1) { dir=(direction)(rand()%4); } breakWall(dir); moveForward(dir); queue.push(xpos); queue.push(ypos); } else { ypos=queue.top(); queue.pop(); xpos=queue.top(); queue.pop(); //queue.pop(); queue.pop(); } } while (startx!=xpos||starty!=ypos); }
void findRouteback (int N, int a, int b, std::vector<int> visited = {}) { for (int i = 0; i < N; ++i) { if (!checkVisited (i, visited)) { ping (a, i); } } }