Movement on risk-like map (regions, not tiles)

Started by
3 comments, last by frob 5 years, 10 months ago

Hi!

Turnbased strategy game: Any good idea on how to implement a risk-like map where armies are moved between regions/sectors on the map instead of on a tilebased map?

My idea is to set each connection manually in the map editor: select a region and then mark each other region it is connected to. When later moving an army these connected regions are the only valid moves. Makes sense? Any way to automate this process?

blank-risk-png.30809

Advertisement

You'd need to have the regions themselves first, don't quite see how to automate that, perhaps semi-automatic flood-fill of an area until you hit yellow or dark colour. From there, you can probably look for neighbouring pixels that belong to another region.

Not sure it's worth the time, doing it manually isn't that complicated, and you don't even need the regions precisely in that case. (Although it may be nice for a player to easily select a region by clicking it on any spot.)

You could use a node based system.

Define each region as one node with x and y coordinates and then link them (e.g. in another array).

If you want you could also make one directional routes that only go in one direction (e.g. you can go from China to India but not back), which would make the linking a bit easier but less logical.

 

for example:

var regionA = {id=>'A', x=>100,y=>200};

var regionB = {id=>'B', x=>10, y=>400};

...

var connections = {};

connections[] = {'A','B'};

 

If you want to have something more detailed you will have to do a much more complex approach which I wouldn't recommend if it is not really necessary.

On 6/5/2018 at 1:55 AM, suliman said:

Any way to automate this process?

Just to be clear, what is being automated?

The game at its core is a connectivity graph. You pointed that out in your own post. 

Since this isn't in For Beginners, we assume you know how to manipulate a graph. Manipulating that type of graph is fundamental in computer science, they are included in the earliest data structures and algorithms courses. Often in the first year of studies they start with trees then include more connected meshes.

 

The other part, creating a connectivity graph out of an image, is not something that can be easily automated. Identifying areas of uniform color is straightforward enough, but anything more than that requires either a human or an enormous amount of computing work. For example, how would you know the British Isles are a single unit, or Indonesia is a single unit? And heaven help the machine that must figure out the mess of northeastern Canada and Greenland.

Don't automate that part. Drop it in an image editor like Gimp or Photoshop, draw boxes around each zone, color each box with an indexed color of 1, 2, 3, 4, etc., and use those to build your clickable regions. When the user clicks on a point, run the coordinate through your indexed image, get the number, and use that to know which node the user picked.  (You can use more complicated regions, but there is no need.)

This topic is closed to new replies.

Advertisement