enter image description here

I'm making a TBS using a hex grid. Player can move units from one hex to another using bridges, which will be randomly generated. I'm using cubic and axial coordinate system for my grid, it's well described in Red Blob Games' Hexagonal Grids.

I don't know how to make a hex understand connection with another one and then calculate best path for units.

I'm not sure how to approach the issue - should I make six slots for bridges in my hex class and then calculate path or should I make movement system somehow and then use absence of bridge as a "blocker"?


1 Answer 1


You can just apply A*( A-star ). Compared to a uniform square grid the only difference is the way you collect the adjacent tiles ( aka your hexagons ).

Each tile should have a table of booleans representing the bridges corresponding to their direction like so

//Depending on your hexagon order
enum Direction{

And in your tile object:

Bool[] bridgeTable = new Bool[Direction.length]; 

In your A* just iterate over your enum list and check the corresponding boolean table that goes with it. This however assumes you always start with the tile which is placed north from the current tile.

For example:

//If there is no bridge
if(!bridgeTable[Direction.NORTH]) continue;
else //calc costs etc

You could also pre-calculate the shortest path from one end to another. If new bridges are added or removed you need to recalculate the table/graph: Floyd_algorithm


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .