Complete.Org: Mailing Lists: Archives: freeciv-ai: November 2003:
[freeciv-ai] Re: (PR#6935) AI sends transports with settlers off explori
Home

[freeciv-ai] Re: (PR#6935) AI sends transports with settlers off explori

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#6935) AI sends transports with settlers off exploring
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxx>
Date: Mon, 24 Nov 2003 08:15:38 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=6935 >

On Mon, 24 Nov 2003, Per I. Mathisen wrote in 2 emails:

> On Mon, 24 Nov 2003, Gregory Berkolaiko wrote:
> > > The problem seems to be the mysterious call to ai_clear_ferry() in
> > > ai_manage_unit(). Why is it there??
> > >
> > > Removing it fixes the problem. Greg?
> >
> > Don't.
> >
> > The reason for the clear_ferry is that the unit, when it's dealt with in
> > it's ai_manage_ function, can try to do lots of various things. Most of
> > them do not involve the ferry that the unit has requested last turn.
> 
> Ugh. This is why I wrote ai_unit_new_role(), you know. _All_ 'changing
> your mind' stuff goes through there. This is the place for such calls.
> 
> I might add that it already takes care of a very related situation:
> Reservations of tiles for city building. I have used this system to keep
> track of reservations for the new settlers system successfully, and it was
> not very forgiving about lost reservations.

There is a crucial difference here.  Settler going to build a city has 
(1) special AIUNIT_BUILD_CITY role and (2) has a spot reserved.  There is 
no (1) without (2) and vice versa (in ideal code).

But there is no AIUNIT_GOING_BY_BOAT role.  It might be going by boat to 
AIUNIT_ATTACK or to AIUNIT_EXPLORE or to something else.  Conversely, if 
it is going to ATTACK, it's not necessarily going by boat.  Even more, if 
a unit was going to attack somewhere and needed boat for it last turn, 
there is no guarantee it will need the boat to attack this turn.

So yes, one can do all boat clearings through 
  ai_unit_new_role(punit, AIUNIT_NONE, -1, -1);
which needs to be issued in the very beginning of ai_military_findjob.  
For now this will suffice.  But why not clear the ferry directly and 
explicitly, in one place?  Much less bug-prone.

> > So we either have to trace every place where a unit changes its mind
> > about using a boat and free the boat there
> 
> Shouldn't be too hard, I think.

I think it will be.  It is possible but will take much debugging time, 
something I am short of right now.

> > This works fine with military units because in ai_manage_military the unit
> > thinks "I am in the middle of the ocean, to go killing I need a boat" and
> > gets the boat back.
> 
> What if the ferry is called first? This looks random to me.

The unit clears it's ferry just before it starts thinking what to do next.  
And after we make sure it has moves left to do something.  It is possible 
ven for a military unit to clear the ferry, try to think of things to do, 
fail to come up with anything and go idle.  But then ferry _should_ take 
over.

To summarize, the easiest model is to clear the ferry just before unit 
starts considering what to do, so if it decides to do something marine, it 
can ask for a ferry again.  However, the settlers got their ferry cleared 
in a relatively random place, which is bad.  I think proper solution is to 
have settlers consider their actions when other units do it.  Another 
solution is to move the clear_ferry call to just before 
ai_manage_military:
http://www.freeciv.org/lxr/source/ai/aiunit.c#L2649

G.

P.S. BTW, thanks for spotting the bug!




[Prev in Thread] Current Thread [Next in Thread]
  • [freeciv-ai] Re: (PR#6935) AI sends transports with settlers off exploring, Gregory Berkolaiko <=