Complete.Org: Mailing Lists: Archives: freeciv-ai: May 2002:
[freeciv-ai] Re: Generalised improvements AI support
Home

[freeciv-ai] Re: Generalised improvements AI support

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <Per.Inge.Mathisen@xxxxxxxxxxx>
Cc: Freeciv-ai <freeciv-ai@xxxxxxxxxxx>
Subject: [freeciv-ai] Re: Generalised improvements AI support
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 7 May 2002 08:31:13 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, May 06, 2002 at 10:29:07PM +0200, Per I. Mathisen wrote:
> On Mon, 6 May 2002, Raimar Falke wrote:
> > > /** This goes in a Building Evaluation Agent or something **/
> >
> > > /* Create a virtual city out of pcity.
> >
> > I'm not a friend of this approach. It is neither very clean (you just
> > don't which field are used and which fields needs initializing) nor
> > does it extend very good (since you don't know which fields are used
> > you have to set them all). I know that the other approach (passing all
> > the required field as parameter or in a struct) is also not this
> > nice. But it is cleaner.
> 
> I don't understand what you're driving at here, Raimar. This cloning can
> be implemented with a very simple memcpy() call.

Ummm yes. I want to avoid constructs like this:

  memset(&virtualunit, 0, sizeof(struct unit));
  virtualunit.owner = pplayer->player_no;
  virtualunit.x = pcity->x;
  virtualunit.y = pcity->y;
  virtualunit.id = 0;
  v = ai_choose_defender_by_type(pcity, LAND_MOVING);  /* Temporary -- Syela */
  virtualunit.type = v;
  virtualunit.veteran = do_make_unit_veteran(pcity, v);
  virtualunit.hp = unit_types[v].hp;

  if (choice->want < 100) {
    want = look_for_charge(pplayer, &virtualunit, &aunit, &acity);

Who says that the binary zero value is neutral in all the unset
fields? Who says what fields will look_for_charge use out of the
second parameter?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "USENET is *not* the non-clickable part of WWW!"


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