Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: patch: make ai understand peace and alliances (PR#1277
Home

[Freeciv-Dev] Re: patch: make ai understand peace and alliances (PR#1277

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Cc: "Per I. Mathisen" <Per.Inge.Mathisen@xxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: patch: make ai understand peace and alliances (PR#1277)
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Mon, 25 Feb 2002 15:20:04 +0100

Dear diary, on Mon, Feb 25, 2002 at 03:03:00PM CET, I got a letter, where
Raahul Kumar <raahul_da_man@xxxxxxxxx> told me, that...
> > > Ah hah. By the way, for Per's info, the AI does establish trade routes.
> > > There are crap routes though, the AI does not seem to check on city size
> > > at all when establishing trade routes.I have never seen it establish a
> > > trade route with a foreign civ.
> > 
> > It doesn't as is obvious from the code - and the TODO implies that as well.
> > 
> 
> Obvious from the code. Hmm must be some new definition of obvious. In
> particular from line 1630 onwards in the ai/aiunit.c. So to be blunt, the
> todo is wrong, and I'm not sure what code you are referring to that makes it
> obvious that the AI does not establish trade routes. 
> 
> I'll expect your grovelling apologies.

1629 in your listing - it iterates only in citiees belonging to pplayer. Per's
second patch is changing that, fullfilling the TODO and removing it :).

>  static void ai_manage_caravan(struct player *pplayer, struct unit *punit)
> 1601 {
> 1602 struct city *pcity;
> 1603 struct packet_unit_request req;
> 1604 int tradeval, best_city = -1, best=0;
> 1605 1606 if (punit->activity != ACTIVITY_IDLE)
> 1607 return;
> 1608 if (punit->ai.ai_role == AIUNIT_NONE) {
> 1609 if ((pcity = wonder_on_continent(pplayer, map_get_continent(punit->x,
> punit->y))) &&
> 1610 build_points_left(pcity) > (pcity->shield_surplus*2)) {
> 1611 if (!same_pos(pcity->x, pcity->y, punit->x, punit->y)) {
> 1612 if (!punit->moves_left) return;
> 1613 auto_settler_do_goto(pplayer,punit, pcity->x, pcity->y);
> 1614 handle_unit_activity_request(punit, ACTIVITY_IDLE);
> 1615 } else {
> 1616 /*
> 1617 * We really don't want to just drop all caravans in immediately.
> 1618 * Instead, we want to aggregate enough caravans to build instantly.
> 1619 * -AJS, 990704
> 1620 */
> 1621 req.unit_id = punit->id;
> 1622 req.city_id = pcity->id;
> 1623 handle_unit_help_build_wonder(pplayer, &req);
> 1624 }
> 1625 }
> 1626 else {
> 1627 /* A caravan without a home?  Kinda strange, but it might happen.  */
> 1628 pcity=player_find_city_by_id(pplayer, punit->homecity);
> 1629 city_list_iterate(pplayer->cities,pdest)
> 1630 if (pcity && can_establish_trade_route(pcity,pdest) &&
> 1631 map_same_continent(pcity->x, pcity->y, pdest->x, pdest->y)) {
> 1632 tradeval=trade_between_cities(pcity, pdest);
> 1633 if (tradeval) {
> 1634 if (best < tradeval) {
> 1635 best=tradeval;
> 1636 best_city=pdest->id;
> 1637 }
> 1638 }
> 1639 }

Oh nice nice, w/o indentation in order to give me some more fun.. thanks! ;)

> > **************************************************************************/
> > > > > > -
> > > > > >  static void ai_manage_ferryboat(struct player *pplayer, struct 
> > > > > > unit *punit)
> > > > > >  { /* It's about 12 feet square and has a capacity of almost 1000 
> > > > > > pounds.
> > > > > >       It is well constructed of teak, and looks seaworthy. */
> > > > > 
> > > > > That comment is ridiculous. Kill it.
> > 
> > Why yes? It's kinda funny and no particular reason why to remove it; the 
> > code
> > has to be a little funny in onder to revive programmer lost in the 
> > wilderness
> > of Syela's code.
> >
> 
> K, funny code is good enough reason. But when the AI crew is done no one else
> will ever get lost in that wilderness again.

It won't be done yet for some time ;). And then we'll find another reason why
to keep it there, I hope :).

-- 

                                Petr "Pasky" Baudis

* elinks maintainer                * IPv6 guy (XS26 co-coordinator)
* IRCnet operator                  * FreeCiv AI hacker
.
No one can feel as helpless as the owner of a sick goldfish.
.
Public PGP key && geekcode && homepage: http://pasky.ji.cz/~pasky/


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