This commit is contained in:
氧原子
2025-04-25 14:33:54 +08:00
parent 5f0d0c5437
commit 6c7fde5740
10 changed files with 582 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
#include<iostream>
#include<string>
#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)))
}