Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


#ActualÁlvaro

Posted 12 September 2013 - 08:12 AM

I haven't thought about it very carefully, but I think I would have three 1-dimensional arrays: hexagons, edges and vertices. Each element should know what other elements it's adjacent to (so a hexagon knows which roads and vertices surround it, an edge knows what hexagons and what vertices it touches...). They should also know their coordinates on the map, but that's only used for representation.

 

Think of what kinds of operations you will be performing very often. For instance, if a player rolls a 9, you'll want to loop over all the hexagons labelled "9", so I would sort the array of hexagons by this number and make a little array indicating the breakpoints between numbers. If you can think of some operation that wouldn't be made fast by the structure I suggested, perhaps it needs tweaking.


#1Álvaro

Posted 12 September 2013 - 07:59 AM

I haven't thought about it very carefully, but I think I would have three 1-dimensional arrays: hexagons, edges and vertices. Each element should know what other elements it's adjacent to (so a hexagon knows which roads and vertices surround it, an edge knows what hexagons and what vertices it touches...). They should also know their coordinates on the map, but that's only used for representation.

 

Think of what kinds of operations you will be performing very often. For instance, if a player rolls a 9, you'll want to loop over all the hexagons labelled "9", so I would sort the array of hexagons by this number and make a little array indicating the breakpoints between numbers. If you can think of some operation that wouldn't be made fast by what the structure I suggested, perhaps it needs tweaking.


PARTNERS