fairland: Move capital initialization to drift() & simplify
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
cde2497a75
commit
3fc24e35b9
1 changed files with 12 additions and 17 deletions
|
@ -506,29 +506,13 @@ allocate_memory(void)
|
||||||
static void
|
static void
|
||||||
init(void)
|
init(void)
|
||||||
{
|
{
|
||||||
int i, j, xx = 0, yy = 0;
|
int i, j;
|
||||||
|
|
||||||
for (i = 0; i < WORLD_X; ++i) {
|
for (i = 0; i < WORLD_X; ++i) {
|
||||||
for (j = 0; j < WORLD_Y; ++j) {
|
for (j = 0; j < WORLD_Y; ++j) {
|
||||||
own[i][j] = -1;
|
own[i][j] = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nc; ++i) {
|
|
||||||
if (xx >= WORLD_X) {
|
|
||||||
++yy;
|
|
||||||
xx = yy % 2;
|
|
||||||
if (yy == WORLD_Y) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"%s: world not big enough for all the continents\n",
|
|
||||||
program_name);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
capx[i] = xx;
|
|
||||||
capy[i] = yy;
|
|
||||||
xx += 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -562,6 +546,17 @@ drift(void)
|
||||||
{
|
{
|
||||||
int turns, i;
|
int turns, i;
|
||||||
|
|
||||||
|
for (i = 0; i < nc; i++) {
|
||||||
|
capy[i] = (2 * i) / WORLD_X;
|
||||||
|
capx[i] = (2 * i) % WORLD_X + capy[i] % 2;
|
||||||
|
if (capy[i] >= WORLD_Y) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: world not big enough for all the continents\n",
|
||||||
|
program_name);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (turns = 0; turns < DRIFT_MAX; ++turns) {
|
for (turns = 0; turns < DRIFT_MAX; ++turns) {
|
||||||
if (stable(turns))
|
if (stable(turns))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue