Saturday, October 28, 2017

Labeling Islands (Part Two)

In the previous post, I looked at labeling island groups.  Island groups are relatively easy to identify because I make them intentionally during world creation.  However, Dragons Abound often creates islands unintentionally as a result of other terrain generation efforts.  For example, if Dragons Abound uses a noise function to create a base terrain, that often results in some islands.  I showed this example in the previous posting:
The two islands above the "Lost Coast" label are examples of incidental islands.

To label these islands, I first need to identify them.  This isn't too hard; Dragons Abound already identifies coastlines, so the islands can be identified by looking for coastlines where the start and the end are the same point.  Here's an example of that algorithm applied to a map:
The green outlines indicate islands.  There are a couple of things to note.  First, this has identified "Zhan Cay" as an island.  It is an island, but it was created by the algorithm that adds peninsula island chains and so already has a label.  Secondly, it has not identified the island in the lower right that is partly off-screen.

To address the first problem, I'll keep track of islands that are in island groups.  I may still want to label islands that are in island groups (especially large ones) but at least this way I'll know when an island is in a group.

The second problem arises because Dragons Abound doesn't close paths that vanish off-screen.  If it did, the coast for every land mass would be closed and detected as an island -- for example the middle land mass in the image above would be a big island.  And there's nothing to say that even small islands like the one in the above image are really islands; it could be just the tip of a large land mass.  Still, land masses like the small one in the lower right at least seem like islands and I probably should detect them as such. A reasonable compromise is to accept a land as an island if it is both (1) fairly small, and (2) the off-screen gap is not too big.

With these rules in place, only the upper island gets a name:
Here's a map where this doesn't work so well;
"Pir Lir Isle" is fine, but "Ozod Island" doesn't appear to be identifying any island.  It's just floating out in the middle of the water.  How did that happen?  Let's highlight the island outlines to see what it thinks it is labeling:
Aha!  The algorithm has detected a path that could be closed off-screen to create a loop -- but rather than being a (potential) loop around an island, it's a (potential) loop around a lake within a bigger piece of land.  So I need to modify the algorithm slightly to reject a path that encloses water rather than land.  As I've mentioned previously, my path-making algorithm always puts the water on the left-hand side of the path, so in this case, all I need to do is reject paths that run clockwise.

Here's another portion of that same map:
I'm not entirely sure I like the look when a number of islands in an area all get labeled; it gets a little busy and cluttered.  Let's take a look at a map with lots of islands.  It turns out to be a mild problem to try to generate a map like this; Dragons Abound has some safeguards that try not to generate maps that are mostly ocean (because those are likely boring) so I have to do some tweaking to get the right parameters in place:
Overall, this is surprisingly non-terrible.  :-)  There are a few obvious problems.  The label for the big island ("Chinsom Isle") looks out-of-place -- I think a human map-maker would certainly put it along the south side of the island.  For reasons that are not obvious to me, the label for "Amtun Island" clashes with another label and crosses the island.  There's clearly room below the island for the label, so I'm not sure why it is placed as it is.  Most of the rest of the labels are pretty well placed.

Of course, placing island labels on a crowded map can be challenging even for good map-makers:
This map has better placement than Dragons Abound can manage but it still has a few problematic spots.  Still, it suggest a few improvements to the way I'm doing island label placement, so in the next post I'll see if I can tune up my island labels a bit.

No comments:

Post a Comment