2025.5.17第二次提交,添加根据实机调试修改的版本

This commit is contained in:
氧原子
2025-05-17 15:12:16 +08:00
parent 5ce7796b14
commit 47a4473330
15 changed files with 940 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
#include<iostream>
#include<string>
#include<vector>
#include"eyebot++.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 *map, int *copy_wall)
{
int size_x = mark.size();
int size_y = mark[0].size();
for (int k = len -1; k >= 0; k--)
{
if (i > 0 && !copy_wall[(i * (size_y + 1) * 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) * (size_y + 1) * 2) + (j * 2) + 1] && map[((i+1) * size_y) + j] == k) //前一个单位的西面是当前格,即当前格子的右侧为上一个格子
{
i++;
path[k] = 1;
}
else if(j > 0 && !copy_wall[(i * (size_y + 1) * 2) + (j * 2) + 0] && map[(i * size_y) + (j-1)] == k) //前一个单位的北面是当前格,即当前格子的下侧为上一个格子
{
j--;
path[k] = 0;
}
else if (j < size_y - 1 && !copy_wall[(i * (size_y + 1) * 2) + ((j+1) * 2) + 0] && map[(i * size_y) + (j+1)] == k) //前一个单位的南面是当前格,即当前格子的上侧为上一个格子
{
j++;
path[k] = 2;
}
else
{
LCDPrintf("ERROR");
}
}
}
/*---通过path数组移动到目标点函数---*/
void drive_path(int len, int *path)
{
for(int i = 0; i < len; i++)
{
go_to(path[i]);
}
}