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

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

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv AI development <freeciv-ai@xxxxxxxxxxx>
Subject: [freeciv-ai] Re: [RFC] Ferry code
From: Gregory Berkolaiko <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Sat, 5 Apr 2003 14:03:19 +0100 (BST)

Hi,

On Sat, 5 Apr 2003, Per I. Mathisen wrote:

> 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.

The problem with such pick-up points is that they cannot build boat (this 
is the problem with Raimar's proposal too).  This can be solved by "future 
expansion 1", but then we'd need to store list of pickup points and all 
this.  I think it's not worth the trouble.

> > 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

At this point the search time becomes exponential as we need to construct 
sub-pf-map for each ferry to estimate time to T(i).

> 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
> T(i).
> 
> 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
> waypoints.

just send them (x, y) coordinates.

> > 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.

Yes, but, err..., see below.

> > 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.

Sounds good to me.  Once settlers and diplomats are in, we just need to 
make attacking units more resolute. Hopefully, Jordi will help here.

Is there any way settler code can be put in before ferries?  They would 
make a better testing ground than diplomats, I think.

> > 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

Even so, there are "urgent" and "not urgent" defenders.  Now, there is no 
clean way to tell between the too, you use rather circumstantial evidence.  
One extra field in the choice struct will do the job.

> 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.

Then I don't understand what you mean by AI build lists...

G.




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