Complete.Org: Mailing Lists: Archives: freeciv-ai: May 2003: [freeciv-ai] Re: New settler code v7

# [freeciv-ai] Re: New settler code v7

[Top] [All Lists]

 To: "Per I. Mathisen" Cc: Freeciv AI development Subject: [freeciv-ai] Re: New settler code v7 From: Gregory Berkolaiko Date: Tue, 13 May 2003 17:42:02 +0100 (BST)

```Code is great and the numbers you provide are amazing.  But there are
suspicious places around.

1. In citymap_reserve_city_spot:
* in the comment you talk about city_mindist.  But there is no sign of it
in the code.
* you use city_map_checked_iterate but don't use city coordinates, it is
confusing
* in the second iterate you again increase the positive values, why?
can't you do both in one iterate?

2. In citymap_free_city_spot there is a condition
if (citymap[x1][y1] == -id || citymap[x1][y1] == id) {
why is the second condition there?

3. In cityresult_fill and city_desirability
* the condition in
} else if (!city_center) {
is not needed.  city_center case is already caught by the previous if
* the division into cityresult_fill and city_desirability is not very
logical, you do some of the checks there and some of the checks here.
Please sort it out, it causes bugs (see next).
* in cityresult_fill if !virtual_city you adjust by corruption.  When you
result->total = result->best_other;

4. In find_best_city_placement
/* This ugly algorithm punishes long treks exponentially. */
This ugly (and here you are absolutely right) algorithm has nothing to do
with exponentials.  The result of the computation (modulo interger arithm.
errors) is
result.total -= ai.perfection * (turns * turns + 3 * turns + 4) / 4;
Maybe we can simplify it to
result.total -= ai.perfection * turns * (turns - 1) /4;
(which is also quadratic) then and remove (turns > 1) condition, which
will be automatically ensured?

5. A comment: placing cities on the spots worked by the non-allies is not
just possible, it's a clever thing to do!

On Wed, 7 May 2003, Per I. Mathisen wrote:

> I think it is ready to go in. There a lot of stuff that can be improved, I
> am sure, but it is better to do this as we proceed with ferry support. The
> addition of ferries will no doubt expose a lot of necessary redesign. So
> unless there are problems with the design itself, I don't want to spend
> more time now optimizing it.

No more optimization, but fixing bugs that we see now should be also done
now, I think.

G.

```