Complete.Org: Mailing Lists: Archives: freeciv-ai: April 2003:
[freeciv-ai] Re: [RFC] Ferry code

[freeciv-ai] Re: [RFC] Ferry code

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: [RFC] Ferry code
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 5 Apr 2003 11:05:30 +0000 (GMT)

On Fri, 4 Apr 2003, Gregory Berkolaiko wrote:
> Setup: unit U on continent 1 wants to move to Z on continent 2.
> We make a big map for U to go to all coastal towns T(i)

What if there are no coastal towns? In this case I suggest we make a
temporary pick up point in the closest ocean adjacent tile to U.

> on 1 where it will spend
> approx N(i)turns waiting, then from each town we calculate paths to all coast
> tiles of continent 2, from all coastal tiles we calculate all paths to Z.
> As an ingredient we will need thesenumbers N(i) which I think we should just
> WAGuess (maybe taking into account boats which are "registered" at that city 
> and
> the production output of the city).

We don't need to WAG it. If there is a boat waiting at T(i), waiting time
is zero. If there is a boat headed back to T(i), it should know how long
it takes to get there (we should store time-to-goto-target in
punit->go->time), which becomes waiting time. If there is no boat waiting
or on its way, we can cycle through all ferries that are idle, and find
the one which takes the least turns to go to T(i), and this becomes our
waiting time. If we go to T(i), we also send this ferry on its way. If
none of the above work, waiting time becomes time to build a ferry at

This should give pretty accurate numbers, except for the last, which is an
ideal estimate (city has nothing more important to build). We should also
reserve ferries using punit->ai.ferryboat.

> Once a route has been decided (say, U will walk to Geneva from which it will
> sail toParis from which it will walk to London), U sets London to be it's
> ultimate dest and Geneva to be it's waypoint.

This will need a new do_unit_goto() and goto_is_sane() that understand

> If Geneva cannot find a boat, it will make a mental note of "need a boat for 
> U".
>  Thereafter, each turn Geneva will check if U is still alive and on the way to
> Geneva.If this is the case, Geneva will try to build set the boat as the
> production for this turn.Otherwise, the note will be deleted.

Shall we use this opportunity to introduce AI build lists? For now, only
for ferries.

> There are two points where present code might not be ready for this:
> 1. Making sure that once a unit is on the way somewhere, it will not suddenly
> change it's mind and go exploring instead.Per, what's the situation now?

For our new ferries: The situation will be good. Just give such units a
unique role and snatch it in ai_manage_unit() before findjob screws around
with it.

For diplomats: The situation is good.

For everything else: Not good. We need to free ferries on the whim of
units whenever they change AI roles. The good news is that we now have
gated all changes in "what we do" through ai_unit_new_role(), so we can
free ferries there.

If we don't want to accomodate this whimsical code, I suggest we leave the
old ferry code in charge of this mess, and concentrate on making the new
ferry code work with diplomats as a test case. Then I will make my new
settlers code work with it.

> 2. Making sure that a boat is built unless thecity has something really urgent
> to do.For this, I think, we need a system of urgency categories for a build.
> I suggest: 1 - normal, 2 - boat, 3 - civil urgency (aka unrest), 4 - military
> urgency.

I suggest we just snatch production after we've considered defenders. It
would be nice if we made code that snatched production before this for
anti-unrest production (temple).

> Future expansions:
> 1. The boat does not have tobe built in Geneva.It can be put in a "global
> queue" with the note that it is needed in Geneva and then "global advisor" 
> will
> assign it to a nearby coastal city.

This is nice, but not very important. Usually we will walk to the city
best suited to build our ship.

> 3. We can keep a tab on how busy each port has been and how long were the
> delays.This can be fedback to (a) numbers N(i) and (b) free boats to tell them
> to go to busy ports looking for an odd job.

I don't think this is necessary.

  - Per

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