使用DFS算法为迷宫中的汽车寻找出路(C编程)

发布于 2024-09-29 07:28:38 字数 134 浏览 5 评论 0原文

大家好,谁能帮我解决 DFS 算法: 路径* agent_DFS (void* arg1,...); 这是用 C 程序编写的,是关于人工智能的,我必须找到一种方法让汽车达到他的目标..?? 它返回一个路径类型的数组 我对此完全不知道...... 请帮我

hello everyone can anybody help me with the DFS algorithm :
Path* agent_DFS (void* arg1,...);
which is written on C program and is about Artificial intelligence which I have to find a way for a car to his goal ..??
it returns an array of type path
I got absoloutely no idea about that ...
please help me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

始终不够 2024-10-06 07:28:38

递归对于实现这一点很有用。

当您穿越某个位置时,记住该位置是否在您当前的路径上将有助于您避免原地踏步。您可能还想记住哪些地址您尚未去过(有趣的路径)以及您已经确定是死胡同的地址(或者至少对实现您的目标没有帮助)。

如果您正在寻找最佳路径,那么记住路径上的每个地址距离起点和终点(在发现的穿过该地址的最短路径上)有多远(穿过迷宫)也很有帮助。顺便说一句,对于沿最短路径(这些路径可能是多个具有相同距离的路径)的所有地址来说,这两个距离的总和应该相同。

Recursion is useful for implementing this.

Remembering if a location is on your current path as you traverse it will help you not to go in circles. You may also want to remember which addresses that you have not yet been to (interesting paths) and addresses you have already decided were dead ends (or at least not helpful in reaching your goal).

If you are looking for the optimal path then remembering how far (through the maze) each address on a path is from both the beginning and the end (on the shortest path discovered that goes through that address) is also helpful. The sum of both of these distances should be the same for all addresses along the shortest paths (paths because their could be more than one path with the same distance), by the way.

忱杏 2024-10-06 07:28:38

为了了解汽车在迷宫中的位置以及它的来源,它会记录所有的移动(北、东、西、南)。每当你后退时,它不会增加路径,而是从路径中移除(例如,知道你已经走到了死胡同并回来了,有什么意义呢?)。

In order to know where the car is in the maze with respect to where it came from, it keeps track of all moves made (north, east, west, south). Whenever you backpedal, it doesn't add to the path, but rather removes from it (what point is there to know that you've been to a dead-end and come back for example?).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文