What's a good algorithm for finding if two objects are connected in a 2D
grid?
I'm currently in the early stages of developing a game in which players
build spaceships by placing individual systems (cargo bay, weapon
controls, crew quarters, etc.) on a 2D grid. The "root" part of the ship
is the bridge where the captain sits and orders people around. What I need
is an algorithm that can check to make sure that every part is connected
to the bridge, either directly or by connecting to another series of parts
that can be traced back to the bridge. Naturally, a part will be deleted
it it isn't somehow connected to the bridge. Anyone know of an algorithm
that can do this?
No comments:
Post a Comment