FloodFill #2
18
main.cpp
18
main.cpp
|
|
@ -94,23 +94,24 @@ void follow(struct maze maze, class mmstats* mms) {
|
|||
nextcell(mms->x, mms->y, mms->head->prev->value, next_L);
|
||||
nextcell(mms->x, mms->y, mms->head->next->value, next_R);
|
||||
nextcell(mms->x, mms->y, mms->head->next->next->value, next_B);
|
||||
if(maze.mhtn[next[0]][next[1]] == nextmht && !API::wallFront() || API::wallLeft() && API::wallRight()) {
|
||||
if(maze.mhtn[next[0]][next[1]] == nextmht && !API::wallFront() || !API::wallFront() && API::wallLeft() && API::wallRight()) {
|
||||
log("forward");
|
||||
return;
|
||||
}
|
||||
else if(maze.mhtn[next_L[0]][next_L[1]] == nextmht && !API::wallLeft()) {
|
||||
else if(maze.mhtn[next_L[0]][next_L[1]] <= nextmht && !API::wallLeft()) {
|
||||
API::turnLeft();
|
||||
mms->turn(left);
|
||||
log("left");
|
||||
return;
|
||||
}
|
||||
else if(maze.mhtn[next_R[0]][next_R[1]] == nextmht && !API::wallRight()) {
|
||||
else if(maze.mhtn[next_R[0]][next_R[1]] <= nextmht && !API::wallRight()) {
|
||||
API::turnRight();
|
||||
mms->turn(right);
|
||||
log("right");
|
||||
return;
|
||||
}
|
||||
else if(maze.mhtn[next_B[0]][next_B[1]] == nextmht) {
|
||||
else if(maze.mhtn[next_B[0]][next_B[1]] == nextmht
|
||||
|| API::wallFront() && API::wallLeft() && API::wallRight()) {
|
||||
API::turnRight();
|
||||
mms->turn(right);
|
||||
API::turnRight();
|
||||
|
|
@ -118,6 +119,15 @@ void follow(struct maze maze, class mmstats* mms) {
|
|||
log("180");
|
||||
return;
|
||||
}
|
||||
else if(maze.mhtn[next_R[0]][next_R[1]] <= maze.mhtn[next_B[0]][next_B[1]] && (API::wallFront() && API::wallLeft())){
|
||||
API::turnRight();
|
||||
mms->turn(right);
|
||||
}
|
||||
else if(maze.mhtn[next_L[0]][next_L[1]] <= maze.mhtn[next_B[0]][next_B[1]] && (API::wallFront() && API::wallRight())){
|
||||
API::turnLeft();
|
||||
mms->turn(left);
|
||||
}
|
||||
log("error en la matri");
|
||||
}
|
||||
|
||||
int* nextcell(int i, int j, int dir, int ndir[2]) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user