a-star

Too far down the rabbit hole on A*. Need a second pair of eyes

Too far down the rabbit hole on A*. Need a second pair of eyes Question: My A-Star code is posted below, pretty much the same as everyone elses but I’ve gone too far down the rabbit hole and can’t step back and see what’s causing my problem. I have a 2D array and as standard …

Total answers: 1

Why does this implementation of the A* algorithm use only one queue?

Why does this implementation of the A* algorithm use only one queue? Question: I found the implementation of this algorithm in python online and it works. It searches the best path for reaching a point starting from another one. Here is the code: from pyamaze import maze,agent,textLabel from queue import PriorityQueue def h(cell1,cell2): x1,y1=cell1 x2,y2=cell2 …

Total answers: 2

Each group of five stars separated by a vertical line

How to separate each group of five stars by a vertical line? Question: I’m a new one at the world of Python programming. I’ve just, unfortunately, stuck on this, I think, simple exercise. So what I should do is to modify the stars(n) function to print n stars, with each group of five stars separated …

Total answers: 3

psycopg2.InterfaceError: connection already closed / pgr_astar

psycopg2.InterfaceError: connection already closed / pgr_astar Question: I am using psycopg2 to access a postgresql database from python. When I try to run the pgrouting function “pgr_astar” for the shortest path, I receive an error cur = db.cursor() psycopg2.InterfaceError: connection already closed Basically, what happened is: when pgr_astar does not find a path between two …

Total answers: 2

Can I rewrite my expensive pygame functions in C?

Can I rewrite my expensive pygame functions in C? Question: Is it possible for me to find the expensive functions(for example, A* pathfinding) in my pygame game and rewrite them as extensions as outlined here? Is there a speed benefit to doing so? Is there a better (python) solution? I ask this question because I …

Total answers: 2

Running C++ code alongside and interacting with Python

Running C++ code alongside and interacting with Python Question: So my current project is mostly in Python, but I’m looking to rewrite the most computationally expensive portions in C++ to try and boost performance. Much of this I can achieve via simple functions loaded from DLL files, but not everything. I have a multidimensional array …

Total answers: 2

Python – Speed up an A Star Pathfinding Algorithm

Python – Speed up an A Star Pathfinding Algorithm Question: I’ve coded my first slightly-complex algorithm, an implementation of the A Star Pathfinding algorithm. I followed some Python.org advice on implementing graphs so a dictionary contains all the nodes each node is linked too. Now, since this is all for a game, each node is …

Total answers: 3