#include #include #include"eyebot++.h" #include"maze_func.h" #include"maze_parameter.h" using namespace std; void flood() { int num = 0; do { num ++; for (i = 1; i < mazesize_x - 1; i++) { for (j = 1; j < mazesize_y - 1; j++) { if (map[i][j] == -1) { if (i > 1) { if (! wall[i][j][1] && map[i-1][j] != -1) { copy_map[i][j] = map[i-1][j] + 1; } } if (i < mazesize_x - 2) { if (! wall[i+1][j][1] && map[i+1][j] != -1) { copy_map[i][j] = map[i+1][j] = 1; } } if (j > 1) { if (! wall[i][j][0] && map[i][j-1] != -1) { copy_map[i][j] = map[i][j-1] + 1; } } if (j < mazesize_y - 2) { if (! wall[i][j+1][0] && map[i][j+1] != -1) { copy_map[i][j] = map[i][j+1] + 1; } } } } } for (i = 0; i < mazesize_x; i++) { for (j = 0; j < mazesize_y; j++) { map[i][j] = copy_map[i][j]; } } } while (map[target_x][target_y] == -1 && num < ((mazesize_x - 2) * (mazesize_y - 2))) }