Compare commits

..

No commits in common. "22d28d9e73a6a50e62225497515baf5ca2650c29" and "f4e82b4be43707942b98386424972f6ae4bcdda9" have entirely different histories.

View File

@ -26,9 +26,21 @@ void locateWall(struct maze& maze);
void flood(struct maze* maze, struct mmstats* mmstats) {
int i, j;
int prevNum;
int marked[16][16] = { 0 };
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});
@ -39,14 +51,6 @@ void flood(struct maze* maze, struct mmstats* mmstats) {
API::setText(8, 7, 0);
API::setText(8, 8, 0);
/*
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
marked[x][y] = 0;
}
}
*/
while (myqueue.size()) {
i = myqueue.front().x;
j = myqueue.front().y;
@ -79,7 +83,7 @@ void flood(struct maze* maze, struct mmstats* mmstats) {
void flood_start(struct maze* maze, struct mmstats* mmstats) {
int i, j;
int prevNum;
int marked[16][16] = {0};
int marked[16][16];
std::queue<fill> myqueue;
myqueue.push({0,0,-1});
@ -88,7 +92,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) {
@ -177,7 +181,7 @@ void follow(struct maze maze, class mmstats* mms) {
mms->turn(left);
log("bLeft");
}
//log("error en la matri");
log("error en la matri");
}
int* nextcell(int i, int j, int dir, int ndir[2]) {
@ -279,8 +283,6 @@ 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;
@ -299,25 +301,12 @@ int main(int argc, char* argv[]) {
//log(maze.hwalls[stats.x][stats.y]);
}
for(;;){
locateWall(&maze, &stats);
log("returning start");
flood_start(&maze, &stats);
follow(maze, &stats);
if(stats.x == 0 && stats.y == 0) {
log("start");
break;
}
//log(stats.x);
//log(stats.y);
API::moveForward();
updatepos(&stats);
//log(maze.hwalls[stats.x][stats.y]);
}
for(;;) {
locateWall(&maze, &stats);
flood(&maze, &stats);
follow(maze, &stats);
if(maze.mhtn[stats.x][stats.y] == 0){
log("Finish");
log("start");
break;
}
//log(stats.x);