Complete.Org: Mailing Lists: Archives: freeciv-ai: December 2002:
[freeciv-ai] Re: ai govt eval improvement
Home

[freeciv-ai] Re: ai govt eval improvement

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <per@xxxxxxxxxxx>
Cc: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: ai govt eval improvement
From: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Sat, 21 Dec 2002 22:43:06 +0000

Quoting "Per I. Mathisen" <per@xxxxxxxxxxx>:

> Can you send me a savegame for that explorer bug you found?

This is my fix for the bug:

  set_unit_activity(punit, ACTIVITY_GOTO);
  result = do_unit_goto(punit, GOTO_MOVE_ANY, FALSE);
  if (result != GR_DIED) {
    set_unit_activity(punit, activity);
    punit->goto_dest_x = oldx;
    punit->goto_dest_y = oldy;
    return TRUE;
  }

in ai_unit_goto.  It is of course cheating to set the activity directly, but
handle_activity tries to sort out dependencies and this we really want to avoid
here: all we want to do is to flip the activity field...

> Also, here is an improved patch to improve AI evaluation of governments.
> Pille helped me adjust some parameters, and I added some extra logging
> facilities. It has many elements which should raise some eyebrows ;-) but
> in the main should be committed, and the most important parts of it sooner
> rather than later...

I tested this whole thing rather intensively.  It's a bit wet behind the ears,
but here is what I suggest:
1.  Usually AI keeps cities content (so the penalties for unhappiness are rarely
invoked), but at the cost of driving food/production into the red.  This should
be punished!  We either have to increase food/shield-weight for negative
something like 3-fold, or, at least do this:

  if (pcity->food_surplus < 0 || pcity->shield_surplus < 0) {
    freelog(LOG_NORMAL, "Warning, city %s unsustainable, returns %d",
            pcity->name, i);
    i = MIN(i, 0);
  }
  return i;

in ai_eval_calc_city (tested, works slightly better than without the cap).
This helps AI to switch to a more appropriate govt (like communism I saw couple
of times) when it's dying to have a war with a good neighbour.

2. When AI is in democracy, it is often seen:
 a. building an aggressive unit
 b. moving it out to attack
 c. getting disorder in the city
 d. fixing it by creating elvises (and food/shield deficit)
 e. disbanding the unit to fix the deficit (an ai_manage_taxes)
This should be fixed to at least attempting to move the unit back into the city.
It will be a kludge but it will work: the units will stay alive (moving
in-n-out) and when AI has enough of them, it will get so much unhappiness that
it will go for the more war-loving govt.

If I get no reply, I will commit you patch with my cap.
Say, on Monday.

G.

P.S. Despite all my criticism it is fantastic to actually see AI manage under
democracy and then switch to something aggressive and wage intensive war. 
Well done!



[Prev in Thread] Current Thread [Next in Thread]