This is the mail archive of the
xconq7@sources.redhat.com
mailing list for the Xconq project.
Re: AI Build Tips
- From: Hans Ronne <hronne at comhem dot se>
- To: Elijah Meeks <elijahmeeks at yahoo dot com>
- Cc: xconq7 at sources dot redhat dot com
- Date: Sun, 6 Jun 2004 22:52:28 +0200
- Subject: Re: AI Build Tips
- References: <1086532092.1485.284.camel@localhost.localdomain>
>Does anyone have any tips on how to make a unit a more
>appealing choice for the AI to build?
This depends on two things: the unit's plan and whether it is an advanced unit.
For non-advanced units, the build target is decided by
preferred_build_type, a huge and complicated function in ai.c. It does all
sort of calculations having to do with the need for explorers, transports
etc. The best way to learn how it works is to examine the code.
For advanced units, the choice is made by auto_pick_new_build_task in
run.c. However, this function just loads precomputed unit worths into a
utype vector and then picks a weighted random number. So the real choice is
made by the worth functions which live in ai.c.
There is one worth function for each plan type (offensive_worth etc), so
figuring out how they work is easier than for preferred_build_type. For
example, offensive_worth uses the following formula:
u_acp(u) * u_attack(u) * u_range(u) * u_speed(u)
while defensive_worth uses:
u_acp(u) * u_defend(u)
both in combat model 1. For combat model 0, the calculations are more
complicated since there are no absolute attack and defend values. The code
therefore compares the unit to all other unit types in the game and
calculates a relative attack or defend value.
So the short answer to your qestion is that a fast strong unit with many
acps will almost always be preferred over a slow weak unit with few acps.
Hope that helps.
Hans