URL:
  <http://gna.org/bugs/?20824>

                 Summary: Problems in server/generator/mapgen.c: part 1,
balance in make_island() and create_island().
                 Project: Freeciv
            Submitted by: mss_8734
            Submitted on: Fri May 17 16:31:18 2013
                Category: general
                Severity: 2 - Minor
                Priority: 5 - Normal
                  Status: None
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
                 Release: 2.6, possibly older ones
         Discussion Lock: Any
        Operating System: Any
         Planned Release: 

    _______________________________________________________

Details:

Problem 1>
On lines 2169 - 2172 in make_island() we have:
  if (islemass == 0) {
    /* this only runs to initialise static things, not to actually
     * create an island. */
    balance = 0;

I have so far not seen balance set to anything but 1 after an island have been
created, meaning the very first one is consistently one tile larger than the
rest, assuming equal size is requested. This is easily solved by initialising
balance to 1, but it seems to indicate something is wrong with line 2007, in
the initial part of create_island():

  i = islemass - 1;

I also fail to understand the logic behind the handling of balance and the
counter ā€˜iā€™ in make_island(), on lines 2218 - 2236:

    /* keep trying to place an island, and decrease the size of
     * the island we're trying to create until we succeed.
     * If we get too small, return an error. */
    while (!create_island(i, pstate)) {
      if (i < islemass * min_specific_island_size / 100) {
        return FALSE;
      }
      i--;
    }
    i++;
    lastplaced = i;
    if (i * 10 > islemass) {
      balance = i - islemass;
    } else{
      balance = 0;
    }

    log_verbose("ini=%d, plc=%d, bal=%ld, tot=%ld",
                islemass, i, balance, checkmass);


Example log excerpt:
Console: 'generator' has been set to "Island-based" (ISLAND).
Console: 'startpos' has been set to "One player per continent" (SINGLE).
[]: island 1
[]: ini=120, plc=121, bal=1, tot=3328
[]: island 2
[]: ini=119, plc=120, bal=1, tot=3209
[]: island 3
[]: ini=119, plc=120, bal=1, tot=3090
[]: island 4
[]: ini=119, plc=120, bal=1, tot=2971

As can be seen we also get plc = ini + 1. At first glance I thought this was
plc = ini + bal, but it appears the difference is caused by the i++ on line
2227. There is no comment explaining the abbreviations, but judging by
checkmass it appears the actual size of the created island is ini, as
illustrated by the log excerpt below (which also shows that initialising
balance to 1 results in islands 1 and 2 being of equal size):

[]: island 1
[]: ini=229, plc=230, bal=1, tot=3219
[]: ADAPTISLAND: (single) required 1 attempt(s) to create an island with 1
start position(s). Requested size: 230, spent checkmass: 229.
[]: island 2
[]: ini=229, plc=230, bal=1, tot=2990
[]: ADAPTISLAND: (single) required 1 attempt(s) to create an island with 1
start position(s). Requested size: 230, spent checkmass: 229.
[]: island 3
[]: ini=229, plc=230, bal=1, tot=2761
[]: ADAPTISLAND: (single) required 1 attempt(s) to create an island with 1
start position(s). Requested size: 230, spent checkmass: 229.

Generated by:

  while (tries++ <= maxtries) {
      if (make_island(mass, startpos, pstate, DMSIS)) {
#ifdef DEBUG
        log_verbose("%s%s required %d attempt(s) to create an island with "
                    "%d start position(s). Requested mass: %ld, spent "
                    "checkmass: %ld.", logpre_mapgen, logpre_spos,
                    tries, startpos, mass, startcheck - checkmass);
        adaptmass-= mass;
#endif
        return true;
      } else {
        adaptisland_failurelog_place();
        adaptisland_failurelog_verbose();
      }
  }


I'm of half a mind to just remove the ā€˜- 1ā€™ on line 2007, but I fear
breaking something I don't understand properly.






    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?20824>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to