Decomposing a map

Decomposing a map

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Decomposing a map

Post by Anarchid »

So, i imagined myself a problem, that sounds this way:

"Given the following: heightmap, typemap, metal spots, create a voronoi-like diagram using spots for seeds, while trying to keep cells to equal area each, avoiding long-and-narrow cells, and aligning cell edges to obstacles such as cliffs or lava".

So far i've been thinking of using lua pathfinder calls for calculations of distance as a magic bullet for taking height/type into the equation, but i've no real idea on how to balance it out with the equal-area demand.

What i'm hoping to achieve with this is a map is divided into sectors, which can be 'conquered' by units and serve as the game's only (re)source of income, while reusing many of the existing maps made for other spring games.

(because the old approach i used - that's, just dropping a rectgrid on top of those maps - is just ugly, terribad, and doesn't respect the map in absolutely any way; and because i'm not that fond of an idea of making a lot of my own maps from scratch at least right now)

Any ideas/suggestions how i can do this? Is using pathfinder here a good idea or a hopelessly abusive fail?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Decomposing a map

Post by knorke »

so you want oddly shaped borders like in Risk?
Image

unless you want to invent an algorithm for fun/learning i would say make some editor to edit borders by hand.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Decomposing a map

Post by Anarchid »

i would generally prefer convex regions that would be more or less square.

Though, hand-editing sounds like a simple option, but then i'd need to spend time on making all these manual polygons either way, and somehow tag them for all the maps - not sure if that's quicker in any way, so i'll at least experiment with something first.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10454
Joined: 24 Jan 2006, 21:12

Re: Decomposing a map

Post by PicassoCT »

well.. then you basicall need a random generator you give it certain ranges that are allowed (math.random(75,120) degrees).. and let it slave away. Every five or six points you calc the area. Then you need a "open"List of the map, which contains all the still "free" borders. You find the closest one, check if you can fit the cell into the map (and if you have to transform it, is it still within the treshold), then you glue it in, (meeting in the middle with all the neighbours) asign all the borders who are free to the open List. Do so until the break of days.

Alternative: You use sort of kaleidoscope approach. And then distort it in a way that doesent hurt the equal area to much.
Post Reply

Return to “Lua Scripts”