gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Game Design > Looking for a map creation algorithm

#111648 - sirpoonga - Fri Dec 08, 2006 6:16 pm

I've been working on making a clone of dicewars on the DS.

The problem I am running into is figuring how to make the map. I have some ideas as but they don't quite make a map as nice looking at was dicewars has.

I am currently using a hex sprite as a template to draw to an 8bit background. I plan on doing it this way so I can easily change the color of a tile to be drawn.

http://img.photobucket.com/albums/v472/SirPoonga/gamedev/hex/hex_test1.jpg

#111665 - sgeos - Fri Dec 08, 2006 10:14 pm

It looks like they are using a fat brush to paint the areas.

I'd select some a place near the middle of the map, and
mark it as the home cell. Expand that area until it is "big
enough".

Next select a bunch of random points on the map.
Sort them based on proximity to the home area.
Connect them in order. If the point has already
been drawn on by the time you get to it, skip it and
move on.

Code:
continue_painting()
{
  if (!done_painting())
    move_brush_in_random_direction_and_draw();
}

done_painting()
{
  return (is_connected()) && (at_least_min_size() || is_surrounded());
}

move_brush_in_random_direction_and_draw()
{
  move_in_random_direction();
  for (each cell in brush)
    if (EMPTY != map[cell])
      map[cell] = brush_color;
}


You might want to move the brush toward home until
the area connects, and then randomize movement after
that if the area needs to be extended.

-Brendan

#111669 - tepples - Fri Dec 08, 2006 10:28 pm

  1. Initialization: Put the cities in a uniform random distribution.
  2. Repulsion: Several times, for each city, search for the closest city and move the city one step away.
  3. Voronoi diagram: Set the color of each empty tile to the color of the nearest city.

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#111684 - sirpoonga - Fri Dec 08, 2006 11:53 pm

Thanks for the info. I was looking for terms to search for.

I think if I combine the observations I have seen (territory distributions) with the principles behind the Voronoi diagram I can get something that works.