Ajustar algoritmo para regresar al inicio #3

Merged
FisionX merged 4 commits from follow into main 2025-02-06 14:10:21 -06:00
Showing only changes of commit ae5d90f27a - Show all commits

View File

@ -29,18 +29,6 @@ void flood(struct maze* maze, struct mmstats* mmstats) {
int marked[16][16];
std::queue<fill> myqueue;
/*
myqueue.push({6,7,0});
myqueue.push({6,8,0});
myqueue.push({7,6,0});
myqueue.push({8,6,0});
myqueue.push({9,7,0});
myqueue.push({9,8,0});
myqueue.push({7,9,0});
myqueue.push({8,9,0});
*/
myqueue.push({7,7,-1});
myqueue.push({7,8,-1});
myqueue.push({8,7,-1});
@ -92,7 +80,7 @@ void flood_start(struct maze* maze, struct mmstats* mmstats) {
i = myqueue.front().x;
j = myqueue.front().y;
prevNum = myqueue.front().z;
//myqueue.pop();
myqueue.pop();
if (i < 0 || i > W || j < 0 || j > W
|| marked[i][j]==1) {
@ -283,6 +271,8 @@ int main(int argc, char* argv[]) {
API::setColor(0, 0, 'G');
// API::setText(0, 0, "abc");
mmstats stats;
struct maze maze2;
stats.x = 0;
stats.y = 0;
@ -301,11 +291,10 @@ int main(int argc, char* argv[]) {
//log(maze.hwalls[stats.x][stats.y]);
}
for(;;) {
log("returning start");
flood_start(&maze, &stats);
locateWall(&maze, &stats);
flood_start(&maze, &stats);
follow(maze, &stats);
if(maze.mhtn[stats.x][stats.y] == 0){
if(stats.x == 0 && stats.y == 0) {
log("start");
break;
}