URL:
<http://gna.org/patch/?1349>
Summary: Rework (+fix) auto-settler code
Project: Freeciv
Submitted by: None
Submitted on: Tuesday 10/27/2009 at 05:05 CET
Category: None
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email: [email protected]
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
_______________________________________________________
Details:
After hitting a bug (tile is not adjacent) in the auto-settler code and
debugging it I decided to rework the code.
auto_settler_findwork() is split:
- Bbuilding a city (role AIUNIT_BUILD_CITY) is split into
auto_settler_found_city()
- improving a tile (role AIUNIT_AUOT_SETTLER) is split into
auto_settler_dowork()
- auto_settler_findwork() now only considers tile improvement and city
building, picks the best and sets the role, goto_tile and activity
auto_settlers_player() reworked:
- settlermap is reinitialised with auto-settlers on the way to a tile
- auto-settler handled in a loop
+ Phase 1: find them some work, loop as long as units are displaced
+ Phase 2: goto tiles and start activity
+ repeat if any unit had to abort its job
unit.h:
- add enum unit_activity ai_activity to struct unit_ai to keep track of
desired activity at destination tile
evaluate_improvements():
- fix bug that all tiles are -1 turns away
This fixes several issues:
- units actualy prefer a near tile now instead of running across half the
map
- units don't change their mind and run back after crossing half the map
- units don't start going somewhere just to be displaced by the next unit
- units remember their job and don't need to findwork every turn
- instead of processing displaced units recursively all units are iterated
till all have work. I hope this will avoid a cascade effect where a series of
units are repeadatley displaced by a nearer one.
- units wont be moved in a recursive call while they are still finding work
(cause of the is_aacent failure)
Attached patch is a working copy that is somewhat verbose. But I'm too tired
to do any cleanup and fix the debug messages now. It is good enough for
others to play with. The patch is also based on trunk with the variable city
radius and several bugfixes applied already. But that should only offset line
numbers by ~2.
MfG
Goswin von Brederlow
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Tuesday 10/27/2009 at 05:05 CET Name: new_autosettler.patch Size:
20kB By: None
<http://gna.org/patch/download.php?file_id=7127>
_______________________________________________________
Reply to this item at:
<http://gna.org/patch/?1349>
_______________________________________________
Message sent via/by Gna!
http://gna.org/
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev