当前位置: 首页>>代码示例>>Java>>正文


Java Heuristic类代码示例

本文整理汇总了Java中com.badlogic.gdx.ai.pfa.Heuristic的典型用法代码示例。如果您正苦于以下问题:Java Heuristic类的具体用法?Java Heuristic怎么用?Java Heuristic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Heuristic类属于com.badlogic.gdx.ai.pfa包,在下文中一共展示了Heuristic类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: search

import com.badlogic.gdx.ai.pfa.Heuristic; //导入依赖的package包/类
protected boolean search (N startNode, N endNode, Heuristic<N> heuristic) {

		initSearch(startNode, endNode, heuristic);

		// Iterate through processing each node
		do {
			// Retrieve the node with smallest estimated total cost from the open list
			current = openList.pop();
			current.category = CLOSED;

			// Terminate if we reached the goal node
			if (current.node == endNode) return true;

			visitChildren(endNode, heuristic);

		} while (openList.size > 0);

		// We've run out of nodes without finding the goal, so there's no solution
		return false;
	}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:21,代码来源:IndexedAStarPathFinder.java

示例2: initSearch

import com.badlogic.gdx.ai.pfa.Heuristic; //导入依赖的package包/类
protected void initSearch (N startNode, N endNode, Heuristic<N> heuristic) {
	if (metrics != null) metrics.reset();

	// Increment the search id
	if (++searchId < 0) searchId = 1;

	// Initialize the open list
	openList.clear();

	// Initialize the record for the start node and add it to the open list
	NodeRecord<N> startRecord = getNodeRecord(startNode);
	startRecord.node = startNode;
	startRecord.connection = null;
	startRecord.costSoFar = 0;
	addToOpenList(startRecord, heuristic.estimate(startNode, endNode));

	current = null;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:19,代码来源:IndexedAStarPathFinder.java

示例3: PathFinder

import com.badlogic.gdx.ai.pfa.Heuristic; //导入依赖的package包/类
public PathFinder(final CachingIndexedGraph<TileCoordinate> graph) {
    this.graph = graph;
    pathFinder = new IndexedAStarPathFinder<TileCoordinate>(graph);
    heuristic = new Heuristic<TileCoordinate>() {

        @Override
        public float estimate(final TileCoordinate node, final TileCoordinate endNode) {
            return Math.abs(endNode.getX() - node.getX()) + Math.abs(endNode.getY() - node.getY());
        }
    };
}
 
开发者ID:JayStGelais,项目名称:jrpg-engine,代码行数:12,代码来源:PathFinder.java

示例4: searchConnectionPath

import com.badlogic.gdx.ai.pfa.Heuristic; //导入依赖的package包/类
@Override
public boolean searchConnectionPath (N startNode, N endNode, Heuristic<N> heuristic, GraphPath<Connection<N>> outPath) {

	// Perform AStar
	boolean found = search(startNode, endNode, heuristic);

	if (found) {
		// Create a path made of connections
		generateConnectionPath(startNode, outPath);
	}

	return found;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:14,代码来源:IndexedAStarPathFinder.java

示例5: searchNodePath

import com.badlogic.gdx.ai.pfa.Heuristic; //导入依赖的package包/类
@Override
public boolean searchNodePath (N startNode, N endNode, Heuristic<N> heuristic, GraphPath<N> outPath) {

	// Perform AStar
	boolean found = search(startNode, endNode, heuristic);

	if (found) {
		// Create a path made of nodes
		generateNodePath(startNode, outPath);
	}

	return found;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:14,代码来源:IndexedAStarPathFinder.java

示例6: AStartPathFinding

import com.badlogic.gdx.ai.pfa.Heuristic; //导入依赖的package包/类
public AStartPathFinding(AStarMap map) {
    this.map = map;
    this.pathfinder = new IndexedAStarPathFinder<Node>(createGraph(map));
    this.connectionPath = new DefaultGraphPath<Connection<Node>>();
    this.heuristic = new Heuristic<Node>() {
        @Override
        public float estimate (Node node, Node endNode) {
            // Manhattan distance
            return Math.abs(endNode.x - node.x) + Math.abs(endNode.y - node.y);
        }
  };
}
 
开发者ID:yichen0831,项目名称:Pacman_libGdx,代码行数:13,代码来源:AStartPathFinding.java


注:本文中的com.badlogic.gdx.ai.pfa.Heuristic类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。