This month I bring you... another method of creating random maps! This one could be especially useful if you're thinking about entering the BYOBG contest (http://www.byond.com/members/ DreamMakers?command=view_post&post=41489).
Let's skip the small talk. This demo is based on Voronoi diagrams. If you want to know what those are, take a look here:
http://en.wikipedia.org/wiki/Voronoi_diagram
And here's the demo:
http://www.byond.com/members/DreamMakers/files/ gughunter.2008%2D0428/voronoi_src.zip
As the article demonstrates, all you need to build a Voronoi diagram is a bunch of seed points scattered around a plane. Once you have that, you just look at every other non-seed point on the plane and figure out which seed it's closest to. Of course this could take a while, since a plane contains an infinite number of points. But a BYOND map is made of turfs, not points, so the job is a lot easier.
Or it would be -- except I didn't do it that way! Instead, I allowed the seed points to expand at the same rate. This is a pretty unscientific method, since the regions only grow one at a time, so the regions that grow first get any turfs that are equidistant from two or more seeds. Fortunately, this demo isn't about being scientific, but only about creating a viable random map.
The demo offers two basic methods of placing seed points. The first is a grid, in which the seeds are spaced in an orderly manner. This would create pretty dull maps, though, if that was all there was to it; you'd always end up with a uniform bunch of rectangles. So the grid method adds a little gimmick: you get to choose the probability that any given grid point won't get a seed. If you choose a reasonable number, you end up with something that looks kind of like a real city -- the grid is interrupted by irregular regions here and there.
The second method is to place the seeds entirely randomly. This creates much more organic-feeling maps, akin to the game board in Risk. The demo also creates a nice little body of water for you, by picking a base region and wandering around the adjoining regions, filling them with water as it goes.
You may be able to think of other applications. Here are some to get you started:
* Unknown Person, who got a sneak preview, noted "Personally, I don't know what I'd do with it, but it looks like something I'd use if I wanted to make a random anthill." I thought that was a pretty nifty remark, since one of the very first computer games I ever wrote, back in the early 1980's, was called "Anthill" and a little Voronoia might have done it good.
* You could try the old party trick known as "reversing figure and ground." Instead of seeing the borders as streets, what if they're walls? You could create a vast cavern network by digging out some doorways.
* You could give the regions more interesting shapes by randomly joining some of them together before you draw the borders.
* As the Wikipedia entry notes, a Voronoi diagram was famously used to analyze an outbreak of cholera in London (the book "The Ghost Map" tells this story, and is a good quick read). Perhaps you could make an interesting game by keeping the Voronoi diagram hidden, and requiring players to find clues to track down the seed points.
Suddenly, without warning, the article ended!