path-finding

Find all simple path from node A to node B in direct weighted graph with the sum of weighs less a certain value?

戏子无情 提交于 2019-12-19 11:52:38
问题 I have a directed weighted graph G=(V,E), which may have loops . I am trying to determine the best time efficient algorithm to accomplish task: t o find all simple path in G between source and target node with total weight of edges in this path less than certain value (for convenience we denote this value as PATH_WEIGHT_LIMIT) All weights is positive and can be float. So, a prototype of my function will be: def find_paths(G, source, target, path_weight_limit) Result paths may overlap, its

2D waypoint pathfinding: combinations of WPs to go from curLocation to targetLocation

北慕城南 提交于 2019-12-19 10:29:34
问题 Please take a moment to understand my situation. If it is not comprehendable, please tell me in a comment. I have an ArrayList of Waypoints. These waypoints are not in any order. A waypoint has the following properties: {int type, float z, float y, float x, float rotation} This applies to a 3 dimensional world, but since my pathfinding should not care about height (and thus treat the world as a 2 dimensional one), the y value is ignored. Rotation is not of importance for this question. In

How to obtain the state of grid cells based on a specific location on a 2D array

主宰稳场 提交于 2019-12-19 04:15:09
问题 Consider a 2D grid with n rows and n columns (here 75x75). The symbols (tokens) are drawn in each cell on mouse click. The code below is used to draw grid lines and symbols within cells: class DrawCanvas extends JPanel{ @Override public void paintComponent(Graphics g){ super.paintComponent(g); setBackground(Color.WHITE); //Lines g.setColor(Color.BLACK); for(int ligne = 1; ligne < ROWS; ++ligne){ g.fillRoundRect(0, cellSize * ligne - halfGridWidth, canvasWidth - 1, gridWidth, gridWidth,

How to obtain the state of grid cells based on a specific location on a 2D array

匆匆过客 提交于 2019-12-19 04:15:06
问题 Consider a 2D grid with n rows and n columns (here 75x75). The symbols (tokens) are drawn in each cell on mouse click. The code below is used to draw grid lines and symbols within cells: class DrawCanvas extends JPanel{ @Override public void paintComponent(Graphics g){ super.paintComponent(g); setBackground(Color.WHITE); //Lines g.setColor(Color.BLACK); for(int ligne = 1; ligne < ROWS; ++ligne){ g.fillRoundRect(0, cellSize * ligne - halfGridWidth, canvasWidth - 1, gridWidth, gridWidth,

A* Algorithm: closed list contains too many elements / too large

心不动则不痛 提交于 2019-12-18 16:58:53
问题 I'm currently implementing the A* algorithm in JavaScript. However, I've ran into a problem: My closedList seems way too large. Here is a screenshot of the output: What could cause this problem? Is my heuristic calculation wrong? Node.prototype.getHeuristic = function(pos0, pos1) { // Manhatten Distance var horizontalDistance = Math.abs(pos1.x - pos0.x); var verticalDistance = Math.abs(pos1.y - pos0.y); return horizontalDistance + verticalDistance; } Or did I understand/implement something

Unable to implement A Star in java

元气小坏坏 提交于 2019-12-18 16:57:57
问题 I've been trying all day to get this algorithm up and running, but I cant for the life of me. I've read many tutorials on the net, and source code in AS3, javascript, and C++; but I cannot adapt what I am seeing to my own code. I have created an AStar class that has a nested class named Node. The map is a 2D array named MAP. The biggest problem that I am having is pulling the F value in the pathfind function. I have implemented the F = G + H, my problem is the actual AStar algorithm. Can

Where can I find information on the D* or D* Lite pathfinding algorithm?

ε祈祈猫儿з 提交于 2019-12-18 10:05:48
问题 There are links to some papers on D* here, but they're a bit too mathematical for me. Is there any information on D*/D* Lite more geared towards beginners? 回答1: Wikipedia has an article on the topic: http://en.wikipedia.org/wiki/D* Also a D* Lite implementation in C is available from Sven Koenig's page: http://idm-lab.org/code/dstarlite.tar However I find the impenetrable math much easier to read than the C source code ;-) Another implementation of D* Lite (in C++) is available here: http:/

Algorithm to find two points furthest away from each other

﹥>﹥吖頭↗ 提交于 2019-12-17 22:14:46
问题 Im looking for an algorithm to be used in a racing game Im making. The map/level/track is randomly generated so I need to find two locations, start and goal, that makes use of the most of the map. The algorithm is to work inside a two dimensional space From each point, one can only traverse to the next point in four directions; up, down, left, right Points can only be either blocked or nonblocked, only nonblocked points can be traversed Regarding the calculation of distance, it should not be

Python, review and speed up A* algorithm

岁酱吖の 提交于 2019-12-14 03:56:35
问题 I have implemented an A* algorithm to find the shortest path between two points in a grid world. For large path lengths the algorithm takes a very long time. I was first wondering if my implementation is correct, and if any optimization could take place? The arguments for the aStar algorithm, are the current position of you and the position you desire to travel to as (x,y) tuples. The Node.value of a node is a direction to travel (NSEW), getAdjacentNodes() returns a list of nodes directly

build a perfect maze recursively in python

三世轮回 提交于 2019-12-14 03:38:15
问题 I have this project to build a perfect maze recursively by using python. I have a MyStack class which creates a stack to track the path that I go through. And a Cell class which represent each square within the maze and store some information. I think I complete the code but IDLE gives me some error that I couldn't figure out. Here is the code. from random import * from graphics import * class MyStack: def __init__(self): self.S = [] def push(self, item): self.S.insert(0, item) def pop(self):