A star with Multiple objects path finding
- itzvnodm
- Oct 10, 2014
- 2 min read
1. Created a square grid 20x20 nodes in size.
Randomly (and via the mouse) marked some of the nodes as "impassable or blocked".
Allowed each grid node to have a variable cost, via the mouse, 3 variations. For example, road tiles cost 1, forest tiles cost 2, water tiles cost 3.
Visualized the grid.
2. Created 10 game entities that navigate the grid in real-time.
Each entity chooses a random goal grid node as it's destination, perform an A* pathfind to that goal, and then travels along the calculated path to reach the goal. Each node's cost is accounted when path finding.
Each entity performs "seek"-like steering for the intermediate nodes along the path, and "arrival"-like steering for the goal node.
After each entity arrives (stops at) it's goal, it randomly chooses a new goal and keep going.
Allowed one entity to be "marked", to single it out for visualization. Visualized the 'start' and 'goal' nodes, it's current calculated path, and it's steering vector.
Start Node:

Goal Node:

Impassable Node:

Normal Node:

Forest Node: (Cost is 5, greater than normal node)

Water Node: (Cost is 10, greater than forest and normal node)

Hover Car: Uses A star algorithm to find the path to a next goal node in the scene randomly and performs seek / Arrive. The tile cost is taken in account when trying to find the path. Nodes with higher costs are avoided as much as possible. Preference is given in order,
Normal Node > Forest Node > Water Node

A * Algorithm used:

Heuristics will make the frontier expand towards the goal more than it expands in other directions.

Comentários