AI changes of 0.70b1

AI changes of 0.70b1

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

Moderators: hoijui, Moderators

User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

AI changes of 0.70b1

Post by jcnossen »

The AI interface functions haven't actually changed, but what breaks the AI dlls is the use of the cdecl function calling convention instead of the stdcall convention. The calling convention of a function determines what code the compiler generates to push the function arguments on the stack, and how the return value is stored.

To get an AI working:

- remove the WINAPI in the interface functions
- possibly disable and remove the .def file, because cdecl will make the function names already correctly exported in the DLL. You don't need a def file anymore.

because this is also portable code, you should be using the definitions in
#include "ExternalAI/aibase.h"
where DLL_EXPORT is defined.
Look at the JCAI/NTAI/groupAI code to see it in detail.
Dolfhin
Posts: 5
Joined: 23 Feb 2006, 16:40

Post by Dolfhin »

Will the AIs included be update in the default installer? and will you include singelplayer 0.5?
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

hmm i cant get aai compiled with the new source:

at #include SPRING_HASH_SET_H it says:

"c:\Spiele\TA Spring SRC\rts\System\creg\STL_Set.h(6): error C2006: '#include' : expected a filename, found 'identifier'"
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

You probably want to include FeatureDef.h instead of FeatureHandler.h now. I'm trying to minimize the amount of headers an AI needs to include, so if there are other parts that need such things can you report them.
Maybe I can build an AI sdk when I get back from holiday (which is next week).
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

ok i solved the problem simply by including "stdafx.h"

aai is running with spring 0.70 now :)

i'll release a recompiled version later that day
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

^^ XE 4+5 use the old format, hwoever XE6 0.28.10 and one of the 0.29's use the new itnerface.cpp versus old testai.cpp
User avatar
Veylon
AI Developer
Posts: 174
Joined: 21 Sep 2005, 19:45

Post by Veylon »

When can we expect to see the "Error in Global AI" messagebox say which AI team is at fault? Would it help if I wrote up a replacement for the GlobalAIHandler.cpp file?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

hmm, and if you do change the itnerface again and are going todo an iminent release please tell us in advance!!!! For one I'm not happy that most people have an outdated version of NTAI on their computers (XE4).
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

I really cant seem to get KAI working under the new version. I removed all references to WINAPI, deleted the .def file and included aibase.h.
It compiles just fine but when running the game i get the "Incorrect AI dll" error and spring crashes into the little report screen. I have looked into JCAIs code and it all seems right...
Can anyone tell me the steps needed to get AIs working?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Thats because the version was incremented. It's nto enough to change the dll itnerface, you need to change the vs project to take the new spring setup and the new spring source.

And even then submarine has reported sometimes AAI 0.55 doesnt work and gives that error, soemtimes it does, and how ome have experienced it with XE6
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

I did change all the includes etc to the new CVS, hence it compiles just fine. What else do i need to do?
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

have you chosen the correct calling convention (cdecl) ?
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

i havent the slightest clue of what that means... im learning still! how do i set it?
submarine
AI Developer
Posts: 834
Joined: 31 Jan 2005, 20:04

Post by submarine »

if you are using vs.net go to project -> properties -> c/c++ -> advanced

there you can select the desired calling convention. it mainly tells the compiler how to arrange params in stack when calling a function, storing temporary data and how to handle return values

edit: using the wrong calling convention will cause to crash a dll immediately
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

Yeah the convention has always been cdecl! Could anyone be really nice and post ALL the steps taken to ensure their AI worked with the newest version? Its really nasty having a strong spell of motivation but not being able to use it!

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

Post by submarine »

i did:

- make sure cdecl is the current calling convention

- delete any WINAPI statements

- #include "ExternalAI/aibase.h"
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

man i dont know whats wrong, i did all 3 of the above!
I got the testAI and added my files to it, but im getting thousands of errors since i have to redo the includes, but should work once im done...
this is hell!
User avatar
krogothe
AI Developer
Posts: 1050
Joined: 14 Nov 2005, 17:07

Post by krogothe »

As i worked my way through all the errors, i started thinking it must be something else!
Then i realized that my CGlobalAI() had no parameters, and that i had no interface.cpp, and that i am a crap programmer for not noticing it sooner! It always worked before!
It loads up now, still crashing like mad but the new cool stuff like simplified install works!

Thanks for the help guys :twisted:
User avatar
Veylon
AI Developer
Posts: 174
Joined: 21 Sep 2005, 19:45

Post by Veylon »

When I try compiling, I get an error about a UnitDef::GetClass() function that doesn't link. I think that this is related to me creating my own array of UnitDefs (Not pointers to UnitDefs). Would instantiating a new UnitDef (requiring all member variables to exist) cause this? How can I create new Unitdefs under the new system?
Bobris
Posts: 18
Joined: 12 Feb 2006, 17:15

Post by Bobris »

This is part of code, which allows me to use debug version in VC8 of AI and release version of Spring. Maybe it can be helpfull to somebody ...

Code: Select all

#include <vector>
#include <map>
#include <set>
#include <deque>
#include <string>
#include <hash_map>
#include <math.h>
#include <assert.h>

namespace releasestd
{
	class string
	{
		enum
		{
			_BUF_SIZE=16
		};
		int mGarbage;
		union {
			char _Buf[_BUF_SIZE];
			char *_Ptr;
		} _Bx;
		int _Mysize;
		int _Myres; // if ==15 then inplace
	public:
		const char *c_str() const
		{
			if (_Myres<_BUF_SIZE) return _Bx._Buf;
			return _Bx._Ptr;
		}
	};
	template<class K,class V> class map
	{
	public:
		int mGarbage;
		struct _Node
		{
			_Node* _Left;	// left subtree, or smallest element if head
			_Node* _Parent;	// parent, or root of tree if head
			_Node* _Right;	// right subtree, or largest element if head
			struct
			{
				K first;
				V second;
			} _Myval;	// the stored value, unused if head
			char _Color;	// _Red or _Black, _Black if head
			char _Isnil;	// true only if head (also nil) node
		};
		_Node *_Myhead;	// pointer to head node
		int _Mysize;	// number of elements

	};
	template<class V> class vector
	{
		int mGarbage;
		V* _Myfirst;	// pointer to beginning of array
		V* _Mylast;	// pointer to current end of sequence
		V* _Myend;	// pointer to end of array
	};
	template<class V> class deque
	{
	};
	template<class V> class list
	{
	};
	template<class V> class set
	{
	};
	template<class V> class multiset
	{
	};
}
#undef std
#define std releasestd

#include "System/float3.h"
#include "Sim/Units/UnitDef.h"
#include "Sim/Weapons/WeaponDefHandler.h"
#include "ExternalAI/IGlobalAI.h"
#include "ExternalAI/IGlobalAICallback.h"
#include "ExternalAI/IAICallback.h"

#undef std
Last edited by Bobris on 05 Mar 2006, 20:15, edited 1 time in total.
Post Reply

Return to “AI”