Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: patch 4: ai passive diplomacy + alliances fixes + new
Home

[Freeciv-Dev] Re: patch 4: ai passive diplomacy + alliances fixes + new

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: patch 4: ai passive diplomacy + alliances fixes + new difficulty level (PR#1277)
From: "Per I. Mathisen" <Per.Inge.Mathisen@xxxxxxxxxxx>
Date: Fri, 1 Mar 2002 23:03:35 +0100 (MET)

On Fri, 1 Mar 2002, Raahul Kumar wrote:
> I'd like to see a version of your ai difficulty patch that does not really on
> your diplomacy patch.

Eh, but it becomes meaningless if the AI doesn't know about alliances! All
the patch does is ally up the AIs. Anyway, I think the difficulties patch
becomes largely superceded by the teams patch, so don't want it in cvs.

> I also don't know why you still use difficulty levels
> 3,5,7,8 instead of 1,2,3,4.

I wanted to change as little as possible. I make enough bugs as is ;)

> >  If (enemy != 0) it looks only for enemy cities
> >  If (pplayer != NULL) it looks for cities known to pplayer
> >  **************************************************************************/
> > -
> >  struct city *dist_nearest_city(struct player *pplayer, int x, int y,
> >                                 bool everywhere, bool enemy)
> >  {
> > @@ -56,7 +55,7 @@
> >    int con = map_get_continent(x, y);
> >
> >    players_iterate(pplay) {
> > -    if(enemy && pplay == pplayer) continue;
> > +    if ((enemy) && (pplayer) && (!pplayers_at_war(pplayer,pplay))) 
> > continue;
> >
>
>
> Explain what is happening here.

You are to break off the current iteration if you are looking for enemies,
and the player currently considered is not an enemy. The code I made is
functionally identical to the code removed, because pplay will never be
NULL, which is the only case where the new test is not identical to the
old.

>
> > -      if (aunit == punit || aunit->owner != punit->owner) continue;
> > +      if (aunit == punit
> > +   || !pplayers_allied(unit_owner(punit), unit_owner(aunit))) continue;
>
> So in future, will the AI need to be taught that if you are not allied you
> are not necessarily at war with each other?

No, this patch should cover both alliances and peace. The example above is
from reinforcements_value(...), and we will not expect any help from
non-allied players... no, most definitely not.

> >  /*************************************************************************
> > -...
> > +  Use caravans for building wonders, or send caravans to establish
> > +  trade with a city on the same continent, owned by yourself or an
> > +  ally.
> >  **************************************************************************/
> >  static void ai_manage_caravan(struct player *pplayer, struct unit *punit)
> >  {
> > @@ -1821,7 +1836,9 @@
> >       else {
> >         /* A caravan without a home?  Kinda strange, but it might happen.  
> > */
> >         pcity=player_find_city_by_id(pplayer, punit->homecity);
> > -       city_list_iterate(pplayer->cities,pdest)
> > +       players_iterate(aplayer) {
> > +        if (pplayers_at_war(pplayer, aplayer)) continue;
>
> Surely you intended a ! here. Why would you establish trade routes with enemy
> civs?

No, we skip enemy players from the iteration loop that considers
possible trade routes here. Enemy players are not considered.

> > -    if (pcity && (city_owner(pcity) != owner)
> > +    if (pcity && (!pplayers_allied(city_owner(pcity), owner))
> >     && city_got_building(pcity, B_SDI)) return pcity;
>
> Why does the SDI improv matter?

I don't understand the question. We protect our allies. Bonus.

BTW, in a separate patch, I would like to go through all of these
pplayers->player_no == aplayer->player_no like code and replace them with
a new common/players.c function pplayer_is_self(p1,p2) or something. Would
anyone else think that is a good idea? Code encapsulation and readable
code and all that.

Yours,
Per

"What we anticipate seldom occurs: but what we least expect generally
happens." -- Benjamin Disraeli



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