gpt4 book ai didi

algorithm - 寻路算法测试工具

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:02:11 25 4
gpt4 key购买 nike

任何人都知道,一些用于路径查找算法测试的工具。我可以在哪里测试我自己编写的二维网格上的寻路算法。像这样的 http://topfat.blogspot.com/但是我可以在哪里编写和运行我自己的算法。它可以使用任何编程语言。我几乎可以针对任何编程语言调整我的代码。

最佳答案

您是否检查了路径查找算法工具的源代码?我是开发人员之一,该工具是开源的 (Java)。例如你的算法应该实现的接口(interface)是

public interface PathFindingAlgorithm {

/**
* Method for finding path from given start point to goal point
* using Map object. Found path (if any) depends on path finding algorithm
* class that overrides this method.
*
* @param start the point where the search begins
* @param goal the goal point
* @param map Map object the path finding algorithm uses
* @return SearchResult object containing path and possibly other relevant information
* about the search and <code>null</code> if no path is found.
*/
public SearchResult findPath(Point start, Point goal, Graph graph);

添加算法的类 (http://code.google.com/p/topfat/source/browse/trunk/src/algorithms/PathFindingAlgorithms.java):

public class PathFindingAlgorithms {

private Vector<PathFindingAlgorithm> algorithms;

public PathFindingAlgorithms() {
this.algorithms = new Vector<PathFindingAlgorithm>();
addAlgorithm(new AStarAlgorithm());
addAlgorithm(new DijkstraStyleAlgorithm());
}

public Vector<PathFindingAlgorithm> getAlgorithms() {
return algorithms;
}

public void addAlgorithm(PathFindingAlgorithm algorithm) {

if (! this.algorithms.contains(algorithm)) {
this.algorithms.add(algorithm);
}

}

public void removeAlgorithm(PathFindingAlgorithm algorithm) {
this.algorithms.remove(algorithm);
}

我不记得这是否也为 GUI 添加了所有需要的东西。我们几年前就这样做了,所以代码(当然)并不完美。此应用程序中最简单的情况是 Dijkstra,如果您需要更复杂的东西,请检查 A*。

您可以通过 Google Code http://code.google.com/p/topfat/ 查看.如果你做了一些你想提交的事情,我们也可以为你添加写入权限。

关于algorithm - 寻路算法测试工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10217365/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com