Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: freeciv2 kernel,modules and rulesets
Home

[Freeciv-Dev] Re: freeciv2 kernel,modules and rulesets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Andrew Sutton <ansutton@xxxxxxx>
Cc: Raahul Kumar <raahul_da_man@xxxxxxxxx>, Tony Stuckey <stuckey@xxxxxxxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: freeciv2 kernel,modules and rulesets
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Tue, 4 Dec 2001 16:32:35 +0100

Dear diary, on Tue, Dec 04, 2001 at 03:36:02PM CET, I got a letter,
where Andrew Sutton <ansutton@xxxxxxx> told me, that...
> On Tuesday 04 December 2001 07:33 am, Raahul Kumar wrote:
> > Possible ideas
> >
> > An evaluation function for units that compares splits them into three
> > categories
> >
> > good defensive
> > good attacking
> > good other(other will be a very big category)
> >
> > What the function does is compare whether the flags like F_IGTER for the
> > situation( if our city is under attack, should we build one more defensive
> > unit or a diplomat to bribe the attacking units)
> >
> > a) increase movement              b) increase attack like   F_IGWALL
> 
> maybe the ai should do all this stuff when it learns the game rules. it can 
> setup internal tables to handle various conditions. uh-oh, there' people 
> coming to get a city, i'd better build defensive units. what units are good 
> for defense (check my table)... musketmen.
> 
> or something like that.
> 
> each unit can probably contain additional information that tells the ai 
> specifically how to use it. again, or something like that.
Actually, we do this (AFAIK; Raahul, cleanup blow over military section of AI
is still waiting for your patches, and I won't know for sure until that ;).
See roles and flags attributes. At least we claim to, we don't use roles as
much as we probably can. The most relevant part code for this probably is:

int unit_desirability(Unit_Type_id id, int for_defense)
{
  int desire = get_unit_type(id)->hp;
  int attack, defense;
  int for_attack = !for_defense;

  if (unit_types[id].move_type != SEA_MOVING || for_attack)
    desire *= get_unit_type(id)->firepower;

  if (for_defense) desire *= 3;
  else desire *= get_unit_type(id)->move_rate;

  attack = get_unit_type(id)->attack_strength;
  defense = get_unit_type(id)->defense_strength;

  if (for_defense) {
    desire *= defense;
  } else { /* for_attack */
    if (defense > attack) return 0;
    else desire *= attack;
  }

  if (unit_type_flag(id, F_IGTER) && for_attack) desire *= 3; /* overrated? */
  if (unit_type_flag(id, F_PIKEMEN) && for_defense) desire *= 1.5;
  if (unit_types[id].move_type == LAND_MOVING && for_defense) desire *= 1.5;

  return desire;
}

So good luck, we expect patches in a day ;))). This you can find in 
advmilitary.c,
this is cleaned version from my CVS, good luck with official version.

-- 

                                Petr "Pasky" Baudis

UN*X programmer, UN*X administrator, hobbies = IPv6, IRC, FreeCiv hacking
.
  "A common mistake that people make, when trying to design
   something completely foolproof is to underestimate the
   ingenuity of complete fools."
     -- Douglas Adams in Mostly Harmless
.
Public PGP key, geekcode and stuff: http://pasky.ji.cz/~pasky/


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