[freeciv-ai] Re: ai govt eval improvement
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Sat, 21 Dec 2002, Gregory Berkolaiko wrote:
> > 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;
> }
Danger, danger: You should not set activity back here without first
checking if it is a valid activity for the new tile with
can_unit_do_activity(). A player should not be able to move a fortified
unit and immediately resume fortified status, and we might have goto'ed a
transport, for example, where fortifying is an illegal state.
> 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;
Ok, but you should move that MIN() above the freelog. Or better, drop the
freelog - this function is (going to be) a CPU bottleneck.
Also, on a slightly related note, we should set ai->science_priority to
zero once we have researched everything! No point in having Democracy once
we can't research.
> 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.
Might work as an ugly kludge...
A better solution is to make the AI better at solving unhappiness
problems. CM will help. Also avoiding building attack units in cities
where they will cause anarchy is a good idea - first build marketplaces
and temples so that we can upkeep those units, like we first build
barracks now.
Finally, in times of all-out war, ai->shield_priority should be increased,
which will have the side-effect of making the AI choose something other
than Democracy (usually Monarchy or Communism) for government.
> 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!
Thanks. This is going to take a few adjustments to get right, though, in
particular the AI's manhandling of Democracy.
- Per
|
|