第一次提交

This commit is contained in:
氧原子
2025-05-14 12:34:56 +08:00
parent 64518bf42d
commit 8b2d592220
14 changed files with 929 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
#include<iostream>
#include<string>
#include<vector>
#include"eyebot++.h"
#include"maze_func.h"
#include"maze_parameter.h"
using namespace std;
void flood(int *map, int *copy_map, int *copy_wall)
{
int num = 0;
int size_x = mark.size();
int size_y = mark[0].size();
map[0][0] = 0;
copy_map[0][0] = 0;
do
{
for (i = 0; i < size_x; i++)
{
for (j = 0; j < size_y; j++)
{
if (! map[i][j] == -1)
{
if (i > 0)
{
if (! copy_wall[i][j][1] && map[i-1][j] = -1) //左边格子
{
copy_map[i-1][j] = map[i][j] + 1;
num++;
}
}
if (i < size_x - 1)
{
if (! copy_wall[i+1][j][1] && map[i+1][j] = -1) //右边格子
{
copy_map[i+1][j] = map[i][j] + 1;
num++;
}
}
if (j > 0)
{
if (! copy_wall[i][j][0] && map[i][j-1] = -1)
{
copy_map[i][j-1] = map[i][j] + 1;
num++;
}
}
if (j < size_y - 1)
{
if (! copy_wall[i][j+1][0] && map[i][j+1] = -1)
{
copy_map[i][j+1] = map[i][j] + 1;
num++;
}
}
}
}
}
for (i = 0; i < size_x; i++)
{
for (j = 0; j < size_y; j++)
{
map[i][j] = copy_map[i][j];
}
}
} while (map[target_x][target_y] == -1 && num < (size_x * size_y))
}