Advertisement

Automatically adding nodes and edges in a tile based map for A* search

Started by November 24, 2011 11:32 AM
0 comments, last by wodinoneeye 13 years ago
Guys, I would like to know how one would go about adding nodes and edges for a rpg tile based map. My map consists of 32x32 tiles.

Guys, I would like to know how one would go about adding nodes and edges for a rpg tile based map. My map consists of 32x32 tiles.




Make the cost data of the map either a seperate 32x32 array or part of the tile map (an array I assume) - generic edges defines by the regular relation
between adjacent tiles on a 2D grid. (N NE E SE S SW W NW ...)

Make the each nodes cost a single value move difficulty within the tile ( of entering or leaving the tile) with some flag/huge value if its not passable)

Sometimes ive made a larger array 34x34 and filled the outside boundry with the impassible value so that I dont have to special case the
next node selection code (dont have to test if X or Y is -1 or 32 when picking the new open nodes)

If you have elevations then that may be part of the cost calculation (steepness between one tile and the next) that probably already lives in you tile map.

If you have a more complex mapping/movement system, you may have to have a 8-way array for each node/tile that represents
the difficulty/passability from that tile to the 8 adjacent tiles (like if you can jump down a level but not up etc...).. You can now have bi-directional differences for the edges.
That 8 way data would be precalculated for each node/tile of the map (saving on any special conditions/complexities)
--------------------------------------------[size="1"]Ratings are Opinion, not Fact

This topic is closed to new replies.

Advertisement