fairland: Distribute islands more fairly among continents
fairland places islands of random size in random places, subject to minimum distances. Results are often less than fair, in particular when the number of islands per continent is low: some continents have more land nearby than others. Increasing distances between islands doesn't help much. Deities commonly run fairland until they find the result acceptable. The next few commits will tackle this issue. As a first step, this one places islands closest to continents in turn, so that each continent is closest to the same number of islands. A continent is closest to an island when it is closest to each of its sectors. The number of islands must be a multiple of the number of continents now. Since fairland may be unable to place all islands, a continent may still get fewer islands than it should. The next commit will address that. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
446005f84c
commit
74bc8adb63
9 changed files with 3644 additions and 3622 deletions
|
@ -62,7 +62,12 @@
|
|||
*
|
||||
* 3. Place and grow additional islands
|
||||
*
|
||||
* Place and grow islands one after the other. Place the first sector
|
||||
* Each continent has a "sphere of influence": the set of sectors
|
||||
* closer to it than to any other continent. Each island is entirely
|
||||
* in one such sphere, and each sphere contains the same number of
|
||||
* islands (except when island placement fails for lack of room).
|
||||
*
|
||||
* Place and grow islands in spheres in turn. Place the first sector
|
||||
* randomly, pick an island size, then grow the island to that size.
|
||||
*
|
||||
* Growing works as for continents, except the minimum distance for
|
||||
|
@ -457,6 +462,12 @@ parse_args(int argc, char *argv[])
|
|||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
if (ni % nc) {
|
||||
fprintf(stderr, "%s: number of islands must be a multiple of"
|
||||
" the number of continents\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (argc > 3)
|
||||
is = atoi(argv[3]);
|
||||
|
@ -901,13 +912,23 @@ init_spheres_of_influence(void)
|
|||
bfs_run_queue();
|
||||
}
|
||||
|
||||
/*
|
||||
* Is @x,@y in the same sphere of influence as island @c?
|
||||
* Always true when @c is a continent.
|
||||
*/
|
||||
static int
|
||||
is_in_sphere(int c, int x, int y)
|
||||
{
|
||||
return c < nc || closest[XYOFFSET(x, y)] == c % nc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Can island @c grow at @x,@y?
|
||||
*/
|
||||
static int
|
||||
can_grow_at(int c, int x, int y)
|
||||
{
|
||||
return own[x][y] == -1 && xzone_ok(c, x, y);
|
||||
return own[x][y] == -1 && xzone_ok(c, x, y) && is_in_sphere(c, x, y);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue