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...
Detecting which unit killed another one
Moderators: hoijui, Moderators
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
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
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
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
Here, just do this. Ugly, but should work and quickly:
You can do the STL way too, with a set if you want...
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];
}