Tutorial on compiling AIs?

Tutorial on compiling AIs?

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

Moderators: hoijui, Moderators

Post Reply
User avatar
QMan
Posts: 103
Joined: 17 Feb 2006, 01:10

Tutorial on compiling AIs?

Post by QMan »

I'm interested in starting up some AI tweaking and creation, but am having trouble even getting off the ground.

I'm trying to compile some of the existing AIs from the Spring source in Visual Studio .NET 2003, but I keep getting a bunch of errors. Could someone give me a step by step list of things I need to do to get an AI compiled? I'm familiar with some other programming languages, Java, Pascal, Matlab, and some C, but not much experience with C++ or with Visual Studio.

So far I've tried opening up the .vcproj files, opening the TestAI.cpp and running the "Build Solution", "Build TestAI", and "Compile," all of which give file not found errors. The files are present in a different directory, however. Do I need to set the PATH for some of these files? I didn't see too much on how to do this in the readmes or on the Wiki.

Thanks for anyone who can help! :)

-QMan
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I think what you want is to try and run one of the projects in the svn, if you have the entire svn in a folder and dont mess around with folders then try to build NTAI or JCAI you shouldnt get any problems.

If you've downlaoded a later NTAI version (XE4+) then be aware that only XE6/7 will compile atm, or XE4 (from the svn only).

OTAI should need a VS project setup which i wouldnt be able to tell you atm, and AAI is closed source.
User avatar
QMan
Posts: 103
Joined: 17 Feb 2006, 01:10

Post by QMan »

Thanks, I'll try to fool around with it this week.
gnarfhead
Posts: 1
Joined: 19 Mar 2006, 17:58

Post by gnarfhead »

If you want to get the TestAI-Source running just use the "additional Includepathes" from NTAI in the the TestAI-Project (Projectproperties->C++; copy the whole Path-String from NTAI). That worked for me
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

huh? My thoughts would instead be to simpyl remove all the NTAI files save globalAI.cpp/h and itnerface.h, maybe keep include.h, rename the project and delete any code referencing the global class. Once thats been done you should have a raw project all presetup, you might wanna change the output tho from NTAI.dll to whatever.dll
User avatar
QMan
Posts: 103
Joined: 17 Feb 2006, 01:10

Post by QMan »

@gnarfhead: Thanks, that worked great!

@AF: Good idea, I'll try that.

-QMan
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

I'm about to try making an AI too, but only have Visual Studio 6. Do I stand a chance/will it work? :?
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Not a chance. Spring headers are incompatible with VC6, and even if they were you'd still need to compile spring on VC6 which will not work (It's using partial template specialization which vc6 doesn't support)

Your options are compiling spring on mingw (ie: GCC for windows), and developing your AI using that, releasing the source and let others compile it for vs7.
However mingw has not been supported as a build platform yet, so it needs a lot of work to get it building. If you take this path, check http://www.devpaks.org for a lot of precompiled devcpp libraries which can save you a lot of time.

The other option is getting vs7.
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

Just as I suspected :oops:
Thanks
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

the free visual studio 2005 express C/C++ will compile AI's given that you install the platform sdk. You also need the directx 9 sdk fi you want to use it to compile spring. Get it now, as there's a timelimit, afterwhich you need to pay to downlaod it otherwise it's free indefinately
User avatar
Veylon
AI Developer
Posts: 174
Joined: 21 Sep 2005, 19:45

Post by Veylon »

I made OTAI for a good while with VC6!

You can download the VC2003 Toolkit and order VC6 to use it's libraries, headers, and executables by specifying those directories. It's not very convenient, but it is possible.

I'd recommend following AF's advice, though. (I will myself next time I remember to bring a blank CD. Express is nearly half a gig!)
User avatar
unpossible
Posts: 871
Joined: 10 May 2005, 19:24

Post by unpossible »

Ace, 2005 seems to be working...now I just have to figure out what to do!
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I wouldn't recommend using VC6 at all, for one you cant just open an existing AI project and remove AI specific code to get it working.

You can use a gcc based compiler, or the enterprise compiler+codeblocks, DevC++, or try and go it alone using one of the other languages such as delphi/vb/c#/asm etc....

VC.iso (visual studio C 2005 express) was something like 480MB for me, and the platform SDK was soemthign like 1.5GB for em some have said it was 500-800MB for them, but I'd install it then try and compile then get the sdk, if it needs libraries and the sdk si too big then you can use an existing VS installation (anythign above VC6 but not including VC6).

If you want to compile spring you also need the directx sdk adn the vclibs installer zaphod made
User avatar
QMan
Posts: 103
Joined: 17 Feb 2006, 01:10

Post by QMan »

Another question to you AI devs out there. Is there an easy way to check a unit's last hit damage (hit for X, missed for 0, etc), total damage output (hit for XX total since creation), total damage received, and # of kills?

Also, can anyone tell me the formula Spring uses to give xp to a unit?

-QMan
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

Thats a matter of counting and adding up values the engine gives you. Look at the calls for UnitDamaged() etc....

Also try using cb->getunitexperience() instead of working it out for yourself..
User avatar
QMan
Posts: 103
Joined: 17 Feb 2006, 01:10

Post by QMan »

AF wrote: Also try using cb->getunitexperience() instead of working it out for yourself..
I wasn't trying to figure it out myself, I was trying to see if I could back out some information out of it to use instead of tracking so many different variables.

-QMan
User avatar
QMan
Posts: 103
Joined: 17 Feb 2006, 01:10

Post by QMan »

Anyway, figured out the xp thing. Next:

How do you tell if a unit is idle?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

When it becomes idle the engine will call your UnitIdle(int unit) function.

Otherwise it's a messy business with context etc. I once tried calling a unitidle if its current command id was CMD_STOP, and JCAI tracked every command and checked each unit was doing what it was meant todo.

On issuing a command if it returns -1 it is also as good as idle....
User avatar
QMan
Posts: 103
Joined: 17 Feb 2006, 01:10

Post by QMan »

Hmm, then I'll either make a unitidle queue, or check their state like you said.


Going to start a new thread for my AI, with source!
Post Reply

Return to “AI”