Complete.Org: Mailing Lists: Archives: freeciv-ai: January 2003:
[freeciv-ai] Goto coordinates and ai roles

[freeciv-ai] Goto coordinates and ai roles

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Goto coordinates and ai roles
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Thu, 16 Jan 2003 18:42:33 +0000 (GMT)

In the massiveai patch (most of which is now in cvs, but not this), I had
unset goto coodinates set to (-1, -1) and a macro valid_goto() which
checked for this to avoid segfaults.

The good part of it is that it stopped use of unset goto coordinates,
which could lead to unpredictable results. (Yes, this is actually a
problem in the current code.)

The bad part is that it led to a bunch of new, stupid tests to avoid
segfaults, and wasn't very clean API-wise.

Now the need for fixing this problem arises with greater urgency, since
generalised topology will no longer allow us to use (0, 0) with impunity.

So what I've been thinking of doing, is as follows:

Whether a unit has a valid goto destination or not depends on its ai_role.
Certain roles require a null destination, others require a valid
destination. A null goto destination is always (-1, -1).

Goto destinations in the higher level code are _only_ used for gotos that
have more than one turn horizon. This corresponds to the use of the
ai_gothere() function. One turn horizon goto should use ai_unit_goto()
which preserves any existing goto destination or a null coord set.

Furthermore, any use of goto should be gated through goto_is_sane(), which
should be expanded to check for the normality of the goto coordinates.

This schema requires some moderately big changes to the way
ai_manage_units() and below are organized, since it first sets roles, and
then sets targets, which can't be allowed - in the above schema roles and
targets must be set simultaneously.


  - Per

[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] Goto coordinates and ai roles, Per I. Mathisen <=