[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: AI questions

Hi Philipp,

welcome to the list.

On 20.09.2007 20:27, Philipp Sªsse wrote:
To introduce myself to the list I attached my first attempt to
create a map. A small one, but some fun when played with handicaps,
I hope. I did not put it inside a context story, but anyone is
allowed to do so, if it seems worth it.

Haven't tried it, yet, so I will refrain from comments for now.
(Except for one: it's amazing how many people get the shop tiles
wrong... ;-))

1) To check what we need the most you first count what we already
have to attack the enemy on ground/water/air and then how many
units the enemy has on g/w/a. This is what I thought of, but I
don't understand why you consider the defensiveStrength of our
own units (but not their attacking Strength) and the attacking
strength of the enemies units. Or do I misunderstand the code?

Seems so. We check Armour + XP + Firepower + GroupSize, for both
our own units and the enemy's.

2) You choose to produce the unit which has the most power in
the area where we need it most, as long as we can afford it.
Fine, but I would instead take the one with the best relation of
the "usage value" and the cost:
      unsigned short val = (type->Firepower(U_AIR) * amul +
                            type->Firepower(U_GROUND) * gmul +
                            type->Firepower(U_SHIP) * smul +
                            type->Armour() / 2) / type->Cost();
Today, usually the most expensive units are produced, but often
it would be better to produce more cheaper units. I think this
change would already give better decisions in most situations.

Possibly, yes. In some cases you'll get worse, though. E.g.,
you'll have vastly better chances against Heavy Tanks with
Heavy Tanks than with 4 Infantry units. But you may be right
that in most situations the best relation is better.

3) If only one type of unit can be produced due to a lack of
crystals, this one will get produced. So if there is a factory
with a mine included, you will perhaps produce nothing but
infantry although you should better save the crystals to produce
something different. Thus, I would suggest not to check if a unit
can be afforded, but to calculate the best value of all units
which can be produced and afterward perform the check, if we have
enough crystals for the best one. If yes, we produce it, otherwise
we don't produce anything but wait until we can afford the best

True. If you save crystals, though, you should also take into
account whether enemy infantry is near so you don't risk losing
them if you don't spend them immediately. And, of course, this
course of action is only helpful for combined mines/factories,
unless we teach the AI to ferry crystals around...

4) Also, (in a further step) additional checks could be made to
add to the "val": if we need to conquer a building and have no
infrantry, infrantry needs to get a bonus. If the enemy is far
away, faster units should be preferred. If the factory also can
repair (which usually is the case) and nearly-destroyed units
are nearby, some crystals might be saved for repair. And the

Certainly. The main reason such checks don't exist is that
the logic gets awfully complex very quickly and I wanted to
have something working as soon as possible. Plus there is
often a significant number of side effects and special cases.
And once the AI was somewhat working, there was always
something more important that needed loooking at first.
That's not to say someone who's willing to implement that
sort of stuff is not going to be welcome. Far from it.

If you are interested in AI-improvements of this kind, I would
offer to code it. But first I want to check if this is desired
at all, because it would require very much testing to check if
the results are reasonable for existing maps. And I don't want
to waste time on something that will not be used anyhow. (-:

AI improvements have long been on the wishlist. At one point
we've also been thinking about having multiple AI implementations
that map designers could chose from according to the mission
requirements and e.g. the difficulty setting. Provided we
supported that, one very nice way to check whether AI changes
are actually an improvement, would be to pit different AIs
against each other...

Well, to cut a long story short: There's a lot of work left
to be done to improve the AI, and any work towards that goal
would certainly be appreciated.

Okay. Sorry for that long posting and thank you once more for
the great fun!

No need to apologize. Glad to have you here, and thanks for
the thanks ;-)