AIs and Universal Mod Support

AIs and Universal Mod Support

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

Moderators: hoijui, Moderators

Post Reply
User avatar
tow_dragon
Posts: 45
Joined: 05 May 2006, 13:53

AIs and Universal Mod Support

Post by tow_dragon »

AFAIK all currently developed AIs are trying to support as much mods as possible. Support for mods is reached by simple files with different units lists and numbers. But I realized, that making AI supporting mods with so different playstyles like BA and EE is VERY hard to reach. It will consume significantly more CPU power and memory than AI dedicated for one mod, on similar game level (in other words first AI is as hard to defeat as the second). Afterwards, I made a question: So why to make AI with Universal Mod Support? The only answer I've found is because they are more convenient to use. Next, I looked into TSI 0.12 source. I looked for functions with hardcoded unit names. I found only 5. So, next qestion is: why don't move this functions to another dll, or make more sophisticated configuration files with scripting language. Answer for the second part of the qestion was simple: It consumes much CPU and memory and is difficult. But making additional dll for every mod isn't very difficult AFAIK, and not too expensive. So, why nobody tried to do that?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Post by Kloot »

Not all AI's use config-files to achieve universal support, eg. KAI builds tables on the fly each time it's loaded, as does RAI.

Writing one dedicated AI for each major mod would be logistically more difficult (n times as much debugging/testing/maintaining even if individual differences were small) and there'd always be some unsupported mod or other, plus it would tie specific AI versions to specific mod versions, creating a chaos for users and making the idea generally infeasible.
User avatar
tow_dragon
Posts: 45
Joined: 05 May 2006, 13:53

Post by tow_dragon »

Making unit tables eats CPU and memory, also. Anyway, I didn't think about making completely new AI for every mod, but only moving some functions (ie. for choosing buildings to build or units for factories) to dll, that would be loaded with AI (Spring loaded helper AIs every time any unit was selected till the newest verion, so it must be cheap). Most of code would be common. And unsupported mods are normal, ie. RAI don't support mods with hubs and comm shooters.

I remember first versions of TSI, that have a lot of code common with SAI. It usually won with any other AI. I think it is the best proof, that hardcoded names could make AI more difficult to beat.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Sounds that could much easier be done by inheritance hardlinked into the AI (as opposed to DLL hell). Scripting or config files would be even better of course, but if you don't want a full scripting solution and still want for example totally different GetNextBuildingLocation() implementation for e.g. E&E and XTA, inheritance is the way to go.
manored
Posts: 3179
Joined: 15 Nov 2006, 00:37

Post by manored »

Just give me one good ai for BA that im happy. :wink:
User avatar
tow_dragon
Posts: 45
Joined: 05 May 2006, 13:53

Post by tow_dragon »

Inheritance would be good too, but a small upgrade or bugfix or next release of mod with deleted one unit would push us to release new version of AI (due to static linking of course) instead of few times smaller additional dll. And making dll that loads dll would be a nice lesson for me (I have never done it, only read an article about it).

And one good ai for BA could be reached by recompiling TSI 0.12, for example :wink: .
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Post by Kloot »

Then why don't you? ;)

Also, an AI that dynamically loaded 'plugins' for each mod defining its behavior would be very interesting, but I still don't think those plugins would be as small as you propose unless you made its design extremely modular (to a degree not yet seen in any existing AI).
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

still want for example totally different GetNextBuildingLocation() implementation for e.g. E&E and XTA, inheritance is the way to go.
This is what closestBuildSite() should do. Infact if it worked as it was intended there should be no need for seperate build placement algorithms for XTA and EE style games.

The reason such a distinction has been made is because of a failure to fix a gigantic bug in spring that me and zwzsg have been complaining about for a year and a half that ahs since been noticed as the cause fo a huge list of by product bugs, bugs that ahve interfered with AIs and mods, Arghs also complained about it, and one of [tow] has complained recently in Help & Bugs, Veylon had tow rite long checking routines to prevent OTAI building in factories, and players have long complained to me, krogothe, and veylon about AIs building things in factories, and we tell them its not our fault its a spring bug.

Because of this bug I've had to build my own building placement algorithm just so I can get the proper functionality without closestbuildsite()crippling NTai, and even now I'm encountering issues with lack of AI event support thatll need me to write patches for spring. I need to researc into threading now to prevent huge lagspikes anyway. Any quick links on crossplatform threading? Like the boost threading libraries?

As for universal mod support.

I think dlls is a huge no no. No modder will bother with it. They're already unlikely to fire up notepad and change a few tags in a config thats autogenerated for them. Hence NTai Toolkit.

Universal mod support is perfectly possible. Stuff like buildtables may reduce performance but that doesnt mater because they're only autognerated once when the AI starts. And lets face it, there're other autogenerated files that HAVE to be autogenerated if not already cached at startup that take time. For example KAIs prepathing to generate chokepoints.

So Universal build routines are possible, infact I have a nice class that does a lot of the menial work of picking units form a build tree from generic tags like B_MEX -> armmex thats not very hard to port should anyone want it.

However, configs should exist too. Universal build routines arent always choosing the optimum choices though, and sometimes a human can provide knowledge for the AI. As such the user should be able to configure the AI as bet as possible.

Configurability is the gospel of Argh that got him flamed in the AI forum. Its the stuff that makes NTai as powerful as it is, and whats causes me to get pms at users surprised at just how configurable NTai is.

The issue AI makers have is that everyone seems to pick one or the other rather than a mix of the two.

To that end XE10 will be totally scriptable in lua. Keywords can be created and bound to lua scripts, tasklists can be bound to lua scripts rather than lists of keywords for different types of behaviours, and behaviour models specified, with mix and match behaviours like Dgunning and offensive reclaiming or running away, and even entire modules for controlling things such as custom attack systems. And I hope other AIs follow me in that direction.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Kloot wrote:Then why don't you? ;)

Also, an AI that dynamically loaded 'plugins' for each mod defining its behavior would be very interesting, but I still don't think those plugins would be as small as you propose unless you made its design extremely modular (to a degree not yet seen in any existing AI).
Glad you said that. XE9.5 and above use the following generic object type, which will be bound to lua in due time.

Code: Select all

class IModule {
public:
	IModule();
	IModule(Global* GL);
	virtual ~IModule();
	virtual void RecieveMessage(CMessage &message)=0;
	virtual bool Init(boost::shared_ptr<IModule> me)=0;
	bool IsValid();
	bool SetValid(bool isvalid);

	void AddListener(boost::shared_ptr<IModule> module);
	void RemoveListener(boost::shared_ptr<IModule> module);
	void FireEventListener(CMessage &message);
};
I believe veylon used a similair construct in his unreleased OTAI 1.14 code, and jelmer was moving towards this with his Task base class in late JCAI builds.

KAI and AAI though have stuck to fairly rigid structures and designs, peefering appending rather than inheritance.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

You don't have to point out that bug in EACH thread. Note that I actually won't bother reading any post of you that starts by pointing out the same bug for the Nth time...
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

After a year and a half its hard to come to any conclusion other than "they mustnt have noticed"
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

You know better then that...

(Otherwise you would have asked politely whether we knew about it, for example, instead of just spamming the bug report in every thread remotely related to the subject. Or you would have actually put the report in our bug tracker, instead of dumping the same data in random threads like this one.)

Remember that the chance something is fixed is inversely proportional to the amount you whine about it.

Anyway, back on topic.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Since AI's can do it themselfs, it can be said that ClosestBuildSite shouldn't even be in the interface. Every AI has its own small variations in definition of what a good buildsite actually is, and if to take features into account etc. So lets just say its in the interface for backwards compatibility sake and drop the complaining.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

The complaining was due to the fact the bug is so wideranging it affects UI modding and AIs.

However I agree that ideally it should be removed once a viable alternative is implemented, which is what I'm close to reaching.
manored
Posts: 3179
Joined: 15 Nov 2006, 00:37

Post by manored »

Tobi wrote:Remember that the chance something is fixed is inversely proportional to the amount you whine about it.
True... :P
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Then ideally your most likely to get a bug fixed by not telling anyone about it.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

chance = constant / whinage_amount

Then you would get division by zero, so that's not possible either :)
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

Post by Peet »

Hmmm....what about negative whining.
manored
Posts: 3179
Joined: 15 Nov 2006, 00:37

Post by manored »

AF wrote:Then ideally your most likely to get a bug fixed by not telling anyone about it.
The first time you tell the administrators that there is a bug its telling, the rest is whining! :P
Post Reply

Return to “AI”