IGlobalAI performance problem and other issue

IGlobalAI performance problem and other issue

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

Moderators: hoijui, Moderators

Post Reply
cain
AI Developer
Posts: 124
Joined: 09 Aug 2005, 10:04

IGlobalAI performance problem and other issue

Post by cain »

some random thought on the IGlobalAI...

I think there should be the possibility to "disable" some call runtime, to save cpu cycles.

That is: the code is in a dll, so it cannot be inlined, and it's virtual, so will cause a referenced slow virtual call, trashing L1 code chache on the cpu (data chache is already considered trashed, due the high unit count)

This is not a critical issue until a lot of units start to fight each other: then a lot of UinitDamage call are done (imagine a big shot on a lot of pewee), this (common) situation will introduce lag, specially if the UnitDamage contains heavy code, but also an empty function will do.
Another performance issue is caused by unit outside a group. If the AI manages internally unit groups, then finishing a order will call a lot of UnitIdle, introducing lag. For nothing, as the AI could take care for itself of idle units.

Neverthless, these are real useful construct and as to be mantained to provide a complete AI interface, but I think that there should be a "swich" in the CallBack to set that permit to disable these calling:

/**
* enables or disable the UnitIdle
*/
virtual void enableIdleNotify(boolean wanted);

/**
* set the minimum damage value that will trigger
* a UnitDamage call
*/
virtual void enableDamageNotify(float minimumdamage);


Another issue of the unit damage is passing the id of the enemy, wich permit to "cheat" accessing directly enemy position and type.

A thing wich is not clear on the documentation is wether a unit entering the los will trig also a EnteredRadar call (duplicaing calls)
SJ
Posts: 618
Joined: 13 Aug 2004, 17:13

Post by SJ »

I dont think virtual calls are as bad as you think. The DoDamage call on the units is for example virtual in itself so there is not that much to win by not calling the dll there. As for the idle call, that assumes that the unit has gotten an order before which means there has been something sent over the network which should be considered a magnitude more expensive. Besides if one dont call UnitIdle the only way for the ai to know if the unit is finished would be to constantly poll them.

GetPos etc only return data if the unit is in los or radar. Since there can only be 5000 units at the moment you could as well just poll every possible id otherwise.

There will be a call to enteredradar when they enter los if they where not in radar previously.
cain
AI Developer
Posts: 124
Joined: 09 Aug 2005, 10:04

Post by cain »

tanks for clarifications. I'm not so deep into the code to see how all it works.
For now, I'm building generic toolset to help further development of AI.
Anyone interested in a CommandFactory?

apropos: it is safe to pass a command to the callback and then destroy it? It's copied into a unit or it's just referenced?
SJ
Posts: 618
Joined: 13 Aug 2004, 17:13

Post by SJ »

Yes commands can be destroyed after being sent, they are copied to a network buffer immidiatly.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

hmm, cain mail me on what you're doing, I have a similair project inline
Post Reply

Return to “AI”