Discussion:
[crimson-list] Improve AI behavior
Sébastien Dailly
2014-04-07 17:43:31 UTC
Permalink
Hello,

Here is a little patch in order to improve the AI behavior. There is also a little level (minimal case) which explain the difference.

Before explaining the patch, let me explain how AI chose the target to attack (Jens correct me if I'm saying something wrong) :

The AI evaluate the target by applying some modifiers for each unit, and choose the unit with higher value. The modifier is calculated witch stategical indicators (the target can conquer buildings, the target is a transport…)
If two units have the same value, the first is kept.

Once the target has been chosen, the AI look for the best way to attack it. Here, the way to evaluate the best position require operationals indicators (support, wedging, backstab…).

After this small introduction, you can load the testmap (this is a small map this 3 units in each camp facing each other) and see how the AI play (be fair, let the AI start :)) :

As each unit have the same value, the AI select the first one and attack it. But the only way to attack this unit is to go just in front of it, between the two other. No problem, let's go to suicide, orders are orders ! The attack does not do much damages, and the counter-attack is deadly.

In my patch, the attack position is evaluated in the same time as the target estimation and the indicators are evaluated together. (I also added some other modifiers, but you can change them if you want). In this game exemple, the AI first attack a unit on the side, and concentrate its attack on the same unit. The central position, between the skipped in preference of safer position. At the end of turn 1, the AI has a better situation (see the screenshot after first turn, human is blue : the first move is in white, second red, and third cyan).

I would like you make some tests with this new behavior and tell me what do you think of that.

Jens : do you think that it would be easy to add some tests in the compilation process ? I think that that the AI is the more important piece in the code, and I could try to write some test in order to check regression in future evolution, but I'll need help to write the frame.
--
Sébastien
Jens Granseuer
2014-04-08 16:37:08 UTC
Permalink
Post by Sébastien Dailly
Jens : do you think that it would be easy to add some tests in the
compilation process ? I think that that the AI is the more important
piece in the code, and I could try to write some test in order to
check regression in future evolution, but I'll need help to write the
frame.
It shouldn't be too hard to add some kind of test harness, but since I
don't have a lot of time to spend on the project at the moment, I won't
be a big help there.

In the past, we've toyed with the idea of making the AI pluggable, at
least for testing purposes, and having several AIs face off against each
other to see which fared better. I think we did have a working prototype
at one point, but I no longer remember the details (damn, getting old I
am).

I'll try to give your changes a spin soon (I'm curious to see what
happens when the unit in the centre is artillery instead of a tank...)
but once again, no promises...

And a tangential note: please generate patches in unified format.
They're much easier to read at a glance (to me anyway).

Cheers,
Jens
Sébastien Dailly
2014-04-09 20:16:01 UTC
Permalink
Post by Jens Granseuer
Post by Sébastien Dailly
Jens : do you think that it would be easy to add some tests in the
compilation process ? I think that that the AI is the more important
piece in the code, and I could try to write some test in order to
check regression in future evolution, but I'll need help to write the
frame.
It shouldn't be too hard to add some kind of test harness, but since I
don't have a lot of time to spend on the project at the moment, I won't
be a big help there.
Ok, I'll try to see what I can do. I do not know about the C++ world and existing testing framework, but I think that provide some little situations for the AI and test the expected result is a good way to proceed. It allow to collect all the problems and give some help for improving it.
Post by Jens Granseuer
In the past, we've toyed with the idea of making the AI pluggable, at
least for testing purposes, and having several AIs face off against each
other to see which fared better. I think we did have a working prototype
at one point, but I no longer remember the details (damn, getting old I
am).
I'll try to give your changes a spin soon (I'm curious to see what
happens when the unit in the centre is artillery instead of a tank...)
but once again, no promises...
I didn't though of testing inequal situation, but I did it after I read your mail, and it worked as expected :)
Post by Jens Granseuer
And a tangential note: please generate patches in unified format.
They're much easier to read at a glance (to me anyway).
I've joined the patch made with `cvs diff -u` which should be the good format now. (for me, it would be easer to ask you to `git pull` a remote branch
)
--
Sébastien
Loading...