mirror of
https://gitee.com/yyz_o/bk_bishe_pi.git
synced 2025-09-07 23:21:26 +00:00
2025.5.14第二次提交,修改完成全部编译时的报错,除部分警告之外。
This commit is contained in:
@@ -2,35 +2,34 @@
|
||||
#include<string>
|
||||
#include<vector>
|
||||
#include"eyebot++.h"
|
||||
#include"maze_func.h"
|
||||
#include"maze_parameter.h"
|
||||
#include"maze_func.h"
|
||||
using namespace std;
|
||||
|
||||
/*---解迷宫路径到path数组函数---*/
|
||||
void build_path(int i, int j, int len, int *path, int *copy_wall)
|
||||
void build_path(int i, int j, int len, int *path, int *map, int *copy_wall)
|
||||
{
|
||||
int k;
|
||||
int size_x = mark.size();
|
||||
int size_y = mark[0].size();
|
||||
|
||||
for (k = len -1; k >= 0; k--)
|
||||
for (int k = len -1; k >= 0; k--)
|
||||
{
|
||||
if (i > 0 && ! copy_wall[i][j][1] && map[i-1][j] == k) //前一个单位的东面是当前格,即当前格子的左侧为上一个格子
|
||||
if (i > 0 && !copy_wall[(i * size_y * 2) + (j * 2) + 1] && map[((i-1) * size_y) + j] == k) //前一个单位的东面是当前格,即当前格子的左侧为上一个格子
|
||||
{
|
||||
i--;
|
||||
path[k] = 3;
|
||||
}
|
||||
else if (i < size_x - 1 && ! copy_wall[i+1][j][1] && map[i+1][j] == k) //前一个单位的西面是当前格,即当前格子的右侧为上一个格子
|
||||
else if (i < size_x - 1 && !copy_wall[((i+1) * size_y * 2) + (j * 2) + 1] && map[((i+1) * size_y) + j] == k) //前一个单位的西面是当前格,即当前格子的右侧为上一个格子
|
||||
{
|
||||
i++;
|
||||
path[k] = 1;
|
||||
}
|
||||
else if(j > 0 && ! copy_wall[i][j][0] && map[i][j-1] == k) //前一个单位的北面是当前格,即当前格子的下侧为上一个格子
|
||||
else if(j > 0 && !copy_wall[(i * size_y * 2) + (j * 2) + 0] && map[(i * size_y) + (j-1)] == k) //前一个单位的北面是当前格,即当前格子的下侧为上一个格子
|
||||
{
|
||||
j--;
|
||||
path[k] = 0;
|
||||
}
|
||||
else if (j < size_y - 1 && ! copy_wall[i][j+1][0] && map[i][j+1] == k) //前一个单位的南面是当前格,即当前格子的上侧为上一个格子
|
||||
else if (j < size_y - 1 && !copy_wall[(i * size_y * 2) + ((j+1) * 2) + 0] && map[(i * size_y) + (j+1)] == k) //前一个单位的南面是当前格,即当前格子的上侧为上一个格子
|
||||
{
|
||||
j++;
|
||||
path[k] = 2;
|
||||
@@ -45,7 +44,7 @@ void build_path(int i, int j, int len, int *path, int *copy_wall)
|
||||
/*---通过path数组移动到目标点函数---*/
|
||||
void drive_path(int len, int *path)
|
||||
{
|
||||
for(i = 0; i < len; i++)
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
go_to(path[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user