Any AI Pathfinding Tutorials?

I’ve been able to find a bit about A* but it’s all in other code types and nothing the the BGE. Does anyone know of any tutorials or sample .blend’s? I found one example, but it was a very basic grid layout and the player could only move horizontally from one square to another. I would like to avoid using a grid and just place nodes in passable areas instead to make it look more realistic.

I’m moving your support question to the Game Engine Support and Discussion board. The Resources board is for sharing resources only, not for asking questions. For more info, please see the “Read this first” sticky in each Game Engine related board.

Hi there, I have been working on pathfinding recently and hopefully will be able to release it soon.
The pathfinding is quite generic and can run on 100’s of objects at once, but further its still in development and Im optimizing some parts (possibly moving into an actuator)

a pathfinding brick!? drools…

A simple one, no tutorial, only the blend

…they’re templates (a mouse look as well) but they should show you structure and proper logic settings to get you going.
Any chance you could look at my post “changing text variable” and put two cents in?

Blender Power

That works pretty good. Is there anything that explains what all the things do? I want to try and incorperate it into my game and use it to see how well it works for what I’m doing.

Theres some really good pseudo code here:

I recommend you start out with basics. Once you learn the algorithm its alot simpler, so start with a simple layout like a grid.


Here is an excellent article about A* :

Hard to explain, I did it by my self, it took me a week reading about A*, 2 days reading about arrays in python and one more week to get it works.

So I really don’t have the skills to explain how it works in a few lines (moreover in english).

Check it out, slowly, be patient, read about A* algorithm and about nodes. It’s the best advice I can give you.

Here I gave a little explanation

here you have more resources

I’ve read those articles and I think I know the basics, but I’m trying to figure out how I would be able to get the G value for any path in python. Everything else I think I can manage so far to get a basic pathfinding code.

The G value increases as the path goes on, to calculate it add the G score of the previous node in the path to the distance from the previous node to the current node. The start node has a G score of 0.

Heres a diagram to help explain, the blue text is the nodes G score and the red text is the distance between nodes. The path goes from left to right.

You can store the G score on the node or in a dictionary where the node is the key.

Oh I’m sorry, I got the H score and the G score mixed up. I ment the H score and how I would be able to find that value. That’s what really has me confused. Is it the length from the starting node directly to the end node, or the length to the end along the nodes? If its the latter then I need help with that.

Ok I’ve decided to try and incorperate your pathfinding scripts into my game now. I’ve translated all the code and I have two questions:

1 - Where is the sensor named “touch” in the track code? I can’t find it on any objects.

2 - How does the list defining the nodes work?