Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#7249) Auto settlers don't irrigate or mine
Home

[Freeciv-Dev] (PR#7249) Auto settlers don't irrigate or mine

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: use_less@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#7249) Auto settlers don't irrigate or mine
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Jan 2004 17:40:36 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7249 >

> [jdorje - Fri Jan 23 00:35:08 2004]:
> 
> > [use_less - Fri Jan 23 00:16:52 2004]:
> > 
> > I decided to try to fix it myself.
> > 
> > This patch adds a plus sign.  :)
> > 
> > I have no idea if this is correct, but it seemed like the simplest fix
> > to me, based on what the comments in the consider_settler_action()
> > function said.  I tested it out quickly, and settlers do irrigate and
> > mine now, but don't replace existing irrigation with mine and vice
versa.

> Autosettlers will generally only improve terrain that is in use by a
> city (except for roads which are built anywhere).  Having never looked
> at this code before, I always thought this was intentional (although bad
> behavior).  But I think you are right and this is just because of a
> 4-year-old typo in consider_settler_action.

OK, I take it back.  Using = here is correct; += is wrong.  newv
acquires a new meaning after the calculation: its previous value is the
overall value of the new tile, whereas its new value is a calculation of
how much the improvement to the tile is worth (roughly corresponding to
a difference between the new value and the old value of the tile).

However there are several things that can cause the value of the
improvement to drop to 0 even though the improvement is actually worth
something:

1.  The "extra" value passed to the function is often -1.  This actually
means the calculated improvement value gets penalized.  These values
should pretty clearly be 0.

2.  ammortize().  I don't really know how ammortize works, but if the
value of the improvement is low enough and it takes long enough to
accomplish (including travel time) the best value will end up at 0.

3.  At the end of evaluate_improvements, the best_newv is "adjusted"
based on the cost of maintaining the settler unit.  If the upkeep is
judged more expensive than the improvement is worth, the value is
decreased to 0.

I think all three would have to be fixed before the settler would
continue working.

I believe this code is used for both human and AI auto-settlers.  For
human settlers the logic is simple: we want the settler to work on the
most productive action.  For AI settlers the AI may want to consider
whether to disband or reassign the settlers, and the above checks may
help with that.  But probably not.

However, after a patch for this I find that autosettlers keep trying to
build impossible bridges.  So seemingly the logic of
evaluate_improvements() is problematic as well.  Geez...

jason



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