Complete.Org: Mailing Lists: Archives: freeciv-ai: February 2004:
[freeciv-ai] Barbarian leader code
Home

[freeciv-ai] Barbarian leader code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Barbarian leader code
From: Mateusz Stefek <mstefek@xxxxxxxxx>
Date: Fri, 13 Feb 2004 13:52:48 +0100
Reply-to: matusik_s@xxxxx

I Found something interesting in logs when debugging:
4: Alaric's Barbarzy??ski Wódz[125] (27,24)->(-1,-1){0,0} Barbarian leader
needs to flee
4: Barbarian leader: closest enemy is Strzelcy at 27, 25, dist 252
4: Barbarian leader: closest enemy is Rycerze at 27, 24, dist -6
4: Generating warmap, pcity = NULL, punit = Rycerze
4: adding cost:0 at 27,24
4: trying get
4: trying get
4: Generated warmap for (27,24).
4: Alaric's Barbarzy??ski Wódz[125] (27,24)->(-1,-1){0,0} Barbarian leader:
moves left: 6.
4: Alaric's Barbarzy??ski Wódz[125] (27,24)->(-1,-1){0,0} Barbarian leader:
fleeing to (27,24).
4: Alaric's Barbarzy??ski Wódz[125] (27,24)->(-1,-1){0,0} Barbarian leader:
reached the safest position.
4: Generating warmap, pcity = NULL, punit = Rycerze

in ai_manage_barbarian_leader() in aiunit.c:2765

 if (closest_unit
      && !same_pos(closest_unit->x, closest_unit->y, leader->x, leader->y)
      && (map_get_continent(leader->x, leader->y)
          == map_get_continent(closest_unit->x, closest_unit->y))) {
    (void) ai_unit_goto(leader, closest_unit->x, closest_unit->y);
    return; /* sticks better to own units with this -- jk */
  }
IMO It's wrong. When leader is on the same tile as closest_unit it decides to
flee! (only works on ocean)

Probably bug is caused by inaccurate check at 2743:
  if (leader->moves_left == 0 || 
      (!is_ocean(map_get_terrain(leader->x, leader->y)) &&
       unit_list_size(&(map_get_tile(leader->x, leader->y)->units)) > 1) ) {
      handle_unit_activity_request(leader, ACTIVITY_SENTRY);
      return;
  }
IMO !is_ocean(map_get_terrain(leader->x, leader->y)) should be removed


Second mistake in this function is that it treats own units as enemies at 2777.
So it tries to run away from them!


--
mateusz



[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] Barbarian leader code, Mateusz Stefek <=