Provinces from Squares

BlitzMax Forums/BlitzMax Programming/Provinces from Squares

Macguffin(Posted 2008) [#1]
Hi all,

I'm trying to figure out how to tackle a problem, and wanted to get your input. Here's what I've got.

My game is a strategy game where I'm trying to:
- Have a province based map (i.e., irregular shapes. Think Risk, Diplomacy, or Europa Universalis.)
- Randomly generate said map.

Right now I've got a square-based grid that has been given height info using Impixi's height map code (thanks, Impixi). This is going to be later layered with other information like temperature, humidity, water level, etc. - but right now I'd like to get things working with just the one mapping.

In order to create the provinces, I'd like to start creating boundaries based on the height map info - for example, if there's a mountain range, draw a border near that. Once a web of province borders has been created and some logical checks have been made to insure they meet specs, create the logical representations of what is now there visually. I can think of a couple ways to approach this. The thing I'm not sure how to approach is turning it into a game map you can play on.

My thought right now is that perhaps I export it to an image and save out whatever pertinent info is needed for various coordinates on it. The game will save out the whole map's image, and then save out important information like coordinates of the province's center point, etc. I'd like to get people's thought on this.

Please let me know if any of this isn't clear, or needs elaboration. Thanks for any help you can offer.


slenkar(Posted 2008) [#2]
you could use 2d polygons
there are lots of 2d polygon routines in the code archives


Warpy(Posted 2008) [#3]
if you're exceptionally clever, you could generate a random set of points and use delaunay triangulation to fill the space with polygons.


Macguffin(Posted 2008) [#4]
Thanks, guys. Looking at both. Pretty sure I'm not exceptionally clever, so we'll see how the later one goes. ;)