Detecting which unit killed another one

Detecting which unit killed another one

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Detecting which unit killed another one

Post by submarine »

To be able to implement some basic learning system for my ai, i want the ai to store information about which unit types get often killed and which often kill others.

the first thing is not a problem, but is there any way to do the second one?
there is EnemyDestroyed(int enemy), but theres no direct information about the killer

is it possible to get the killer from the the unit id?


if not, i would like to request this to be added to the ai interface, because i think it is very important for learning ais...
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

But isn't it more important which enemy is actually doing the damage? I think you first get a call to UnitDamaged anyway, so you could check if it's a lethal damage.
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

that means i would have to check it every time, damage is beeing dealt to a unit - isn´t that a waste of cpu power?

at first, i wanted to keep it very simple:
if a unit gets killed by another type, the effincy of the killer is increased a little bit and vice versa for the killed unit. the increase would be based on the costs of both killer and killed unit, so that stronger units don´t get higher values by killing lots of pewees.

of course, this is not reflecting all situations in the game properly (as by chance even a pewee could kill a krogoth) but i want to experiment on the results of that algorithm after a long playtime
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

that means i would have to check it every time, damage is beeing dealt to a unit - isn´t that a waste of cpu power?
I doubt you could even measure a drop in fps or something. The UnitDamaged call is being done anyway, so you might as well use it.
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

ok agreed,

but this still only provides my ai with information about enemy killers, it´s necessary to get the own killers as well...

theres only enemydestroyed(int enemy), but i don´t know how to get the killer from that


edit: its not absolutely necessary, but it´ll take more time to get sensible values and there must be ais of different sides
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Ok I see your point, but there afaik there is no easy way to make EnemyDestroyed(unit,killer), because I don't think the killer unit is known in the unit destructor.

EnemyDamaged would be a lot easier though, but in any case, I have no time right now, so it will have to wait.
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

i just talked to sj, he proposed to use the units experience instead; i´m not quite happy with that, so im thinking of etending the ai interface..

what do other ai devs think about it?
User avatar
Veylon
AI Developer
Posts: 174
Joined: 21 Sep 2005, 19:45

Post by Veylon »

Here, just do this. Ugly, but should work and quickly:

Code: Select all

int UnitAttacker[10000];

void CGlobalAI::UnitDamaged(int Damaged, int Attacker, etc.)
{
   UnitAttacker[Damaged] = Attacker;
}

void CGlobalAI::UnitDestroyed(int Unit)
{
   int KilledBy = UnitAttacker[Unit];
}
You can do the STL way too, with a set if you want...
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

i (or zaphod to be more precisely) updated spring cvs so it now provides the attacker in EnemyDestroyed and UnitDestroyed
Post Reply

Return to “AI”