Complete.Org: Mailing Lists: Archives: freeciv-ai: March 2004:
[freeciv-ai] Re: paratroopers
Home

[freeciv-ai] Re: paratroopers

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: paratroopers
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Mon, 22 Mar 2004 18:17:35 +0000 (GMT)

On Sun, 21 Mar 2004, Jordi Negrevernis i Font wrote:
> >  Hi, this is a first attempt to teach the AI how to use the
> > paratrooper unit.
> >
> >  It's very simple and can be greatly improved. The wants of the
> > advisor are generally too high.
> >
> >  It's against cvs Feb-27.
> >
> >  I can improve it if you plan to include in cvs.

> >+  /* second, we search for enemy units near us,
> >+     if we don't find any own empty city */
...
> >+  /* third, we search for undefended enemy cities near us */

Err, shouldn't we rather take enemy cities than enemy units? At least we
should weight the two options against each other.

> >+static int find_something_to_paradrop(struct unit *punit, int x, int y)
...
> >+/* first, we search for undefended cities */
> >+square_iterate(punit->x, punit->y, range, x, y) {
> >+  acity = map_get_city(x,y);
> >+  if ((acity) && (city_owner(acity) == pplayer) &&
> >+      (unit_list_size(&(map_get_tile(x, y)->units)) == 0)) {
> >+    /* own city and empty! */
> >+    if (profit < (acity->trade_prod + acity->shield_prod + 
> >acity->food_prod) * acity->size) {
> >+      profit = (acity->trade_prod + acity->shield_prod + acity->food_prod) 
> >* acity->size;
> >+    }
> >+  }
> >+} square_iterate_end;

I am not sure whether this is worthwhile, and even if it is, we should
definitely check whether the city is in danger before building defenders
for it.

Also, why have two different calculations as to profit - one to determine
target and one to build?

> >+/* second, we search for enemy units near us,
> >+   if we don't find any own empty city */
> >+
> >+/* third, we search for undefended enemy cities near us */
> >+
> >+return profit;

Missing code? :)

> >+/*******************************************************************
> >+ * Chooses to build a paratroop if necessary
> >+ ******************************************************************/
> >+void ai_choose_paratrooper(struct player *pplayer, struct city *pcity,
> >+                         struct ai_choice *choice)
> >+{
> >+
> >+/* military_advisor_choose_build does something idiotic,
> >+ * this function should not be called if there is danger... */
> >+if (choice->want >= 100 && choice->type != CT_ATTACKER) {
> >+  return;

assert, not return, IMHO.

Also, beware of line lenghts. Max 80 chars.

It looks good, haven't tested it. I think it should go in, but I want to
hear what Greg has to say about it.

  - Per



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