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

AI questions



Hello everybody,

first of a great many thanks for this great game. After I found
it when looking for a nice tactical game for my mobile phone,
I fell in love with it (by now rather on my iMac than scrolling
on that small 320x240 screen).

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.

Anyhow, on testing the map I found that the AI of the computer
player does not do what I hoped it would. For example I hoped
it would know how to carry crystals from the mine to the factory.
I have to add: I admire how good the AI works in the known maps,
because I know how difficult this kind of stuff is.

I like to help improving the AI, but I think I should start with
an easier aspect: in other maps I already noticed that the
computer player loves to create artillery in his factories,
no matter how useful they seem. I thought of how to decide what
to produce.

Then I checked the AI:BuildReinforcements() and was surprised to
learn that it was already quite like what I thought of. Just
a couple of points that I don't understand completely and some
others which I would change. But before I start to write patches
I first wanted to ask back, because there is always a possibiity
that I simply think the wrong direction ...

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?

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.

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
choice.

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
like.


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. (-:


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

Regards, Philipp.


Attachment: Widerstandsnest.lev
Description: Binary data