Complete.Org: Mailing Lists: Archives: freeciv-ai: April 2003:
[freeciv-ai] New settler code
Home

[freeciv-ai] New settler code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] New settler code
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Mon, 7 Apr 2003 02:01:32 +0000 (GMT)

This is the first public release of my new settlers code, which I have
been talking about for some time. It still needs some work and
optimization, but it is starting to take shape.

Important points to notice:
 -> This code is fully Modpack(TM) compliant. It does not hardcode
Republic or certain buildings, and yet it will calculate city positions
wrt Republic even under Despotism, since it knows we are gunning for
Republic.
 -> Settler inclination to go far from city of origin to find the perfect
spot is controlled by ai->perfection, this variable needs tuning.
 -> Weighting of food vs shields vs trade is done through the aidata
priorities variables.
 -> There is no cacheing. I gave up on that. Still, my code is just a
handful percentages slower than the current code.
 -> It uses pf. It is a very good example of how to use the unit path
iterator. Yay.
 -> Immigration is broken. We don't consider the possibility of adding
ourselves to an existing city at the moment. (Not very high priority.)
 -> The basic algorithm is: Sum up city center and one extra tile, add
bonuses to this, then add other available tiles at /8 base value. Then we
reduce this value exponentially with distance. While simple, this
algorithm gets the job done quite well.
 -> Compared to the old settlers code in getting the job done I think it
is about twice as good. Equal starting conditions, and new code
outproduces old code 2x. It is a bit hard to compare, tho, since my code
doesn't have ferries yet, and old code uses ferries all the time.

Please read & criticize. The plan is to commit it as 'experimental' only
code pending the inclusion of the ferry code (not this version tho).

An open question is if we shouldn't also clean up the terrain improvement
code while we're at it. At present, I just kludge in the current code. But
this can be done later. Big patches are bad.

  - Per

Attachment: newsettler3.diff
Description: Text document

Attachment: citymap.h
Description: Text document

Attachment: citymap.c
Description: Text document

Attachment: aisettler.h
Description: Text document

Attachment: aisettler.c
Description: Text document


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