Headless Spring?

Headless Spring?

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

Moderators: hoijui, Moderators

Post Reply
SiriusDragon
Posts: 14
Joined: 21 Mar 2010, 07:13

Headless Spring?

Post by SiriusDragon »

Hey all,

My previous AI project went OK, but ended up being way too scripted and constrained rather than being able to think for itself. It's still capable of beating other AIs (except E323 :() but I also rushed in alot of hacks at the last minute so it needs redoing.

As a result, for this semester I am creating a Neural Net and/or Genetic Algorithm based AI. Now, NNs require training in order to be effective so I was thinking, if I could somehow have a headless version of Spring I could run multiple copies of the game on my home PC and let the AI 'learn' that way.

Is there a way of making spring headless? ie. No graphical output but behind the scenes it's all the same?

Thanks for any suggestions :) Hopefully this AI will work out better than my previous one :P My goal is for my AI to beat up E323 and other AI's consistently :)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Headless Spring?

Post by AF »

There should be, but if you need to run in normal mode, you can set the minimum and maximum speed via a widget to something ridiculously high like 120x normal speed, hide the UI, the ground, the water, and set viewradius to a tiny portion, coupled with the autoexit on endgame widget.

Combined with a startscript and a batch file, this is how I did my automated batch tests for Shard
SiriusDragon
Posts: 14
Joined: 21 Mar 2010, 07:13

Re: Headless Spring?

Post by SiriusDragon »

That option sounds just as good then :-) But I don't 'need' to run it in normal mode so headless would be nice if possible. I assume there's a command line option or something similar?

Also, thanks heaps AF for your MSVC AI project files. Not everyone wants to go to all the hassle of installing a million command line tools just to be able to make an AI... :P

Does the original project still work with the newer versions of the engine? I assume so considering the AI interface isn't changing until that next big revamp.

I'd like to wait or use the SVN version to get the benefits of the new interface but it's an extra level of uncertainity to add, so I think I'll stick to the old one for now.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Headless Spring?

Post by AF »

You would need ot make modifications, namely downloading the latest C++ wrapper hoijui posted for me, or generating it from source via cmake, then copy pasting it over what I have on my site, then adding those files to the visual studio project. From then on its business as usual.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Headless Spring?

Post by knorke »

I would be interessted in headless spring too.
I already do the low graphic, high speed, autoexit thing but in lobby someone (forgott name) told me headless would be better. I guess it could also run multiple times maybe?
At this moment the only way to get headless spring is to compile it yourself right?
If someone has done so already, I would be happy to have a .exe that runs on 32bit windows xp :)
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Headless Spring?

Post by aegis »

I checked the performance graphs when we made spring-headless, UI was the only performance hit.

my headless_setup widget sets speed to 120x and hides the UI
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Headless Spring?

Post by hoijui »

there is a spring-headless.exe, but it is not shipped with the installer.
you can get it here:
http://springrts.com/dl/buildbot/defaul ... eadless.7z
under linux, you can run it with a real headless system even, if you need all the speed really (i guess, the gain would not be tremendous just because of the headless system).

with the next big revamp, i guess you mean pureint. this has now been merged into master (about a week ago), and will be in spring 0.83.
If you would write a JVM based AI, you could easily create all the necessary stuff for developing an AI with just a JDK and ant installed. using spring source code:

Code: Select all

# Linux
cd AI/Interfaces/Java/bin
ant sdk -Dsdk.home=/tmp/mySpringJavaAISDK

Code: Select all

REM Windows
cd AI\Interfaces\Java\bin
ant sdk -Dsdk.home=C:\mySpringJavaAISDK
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Headless Spring?

Post by gajop »

SiriusDragon wrote: As a result, for this semester I am creating a Neural Net and/or Genetic Algorithm based AI. Now, NNs require training in order to be effective so I was thinking, if I could somehow have a headless version of Spring I could run multiple copies of the game on my home PC and let the AI 'learn' that way.
What would you be using ANNs and GAs for really?

I believe it's a general thought that ANNs are just useless when it comes to game development (and really most of machine learning), and even though GAs are useful sometimes, they are often an overkill for the optimization problem you're faced with (it can probably be solved with more simple things like coordinate ascend/hill climbing/simulated annealing, etc.).

I had experience using GAs to optimize unit targeting in starcraft, and it was slow, although that was made in python and could be further optimized, it most likely wouldn't scale to the size of TA based mods. In the end, I just used coordinate ascend since I didn't have too many cycles to spare on the GA version, and the benefit wasn't noticeable.

I'm not sure entirely what you intend to use ANNs for, but if it's for supervised learning SVMs are probably much easier to implement and often give you a better result - not to mention they're easier to analyze in comparison to ANNs. For unsupervised learning I think K-means are probably much more meaningful than SOM, and if you wanted something more complex you could always aim for hierarchical clustering, then again speed is very important here.

I haven't looked up the entirety of the code of other AIs, but I doubt that any of them are using ANNs, GA or any other pure machine-learning based algorithm. In general, if you wanted more interesting behavior you should look at creating threat/defense regions, have your AI avoid enemy regions with high threat but aim for low threat/high valued(in resources) regions.
Perhaps, if you really wanted to you could use some type of supervised learning to generalize your AIs ability to choose which units to build depending on their stats (or just have it classify them in a couple of classes, like harassment/regular/AA, etc.).

A thing that might be interesting is getting good build orders for maps, I guess that would be a part of reinforcement learning or similar sequence-based learning. Then again, this is something that you would probably do off-line and maybe create a decision-tree model of possible build options - but in all likelihood, there aren't and probably never will be enough replays to give you a good enough model after 10-15 buildings given the amount of maps, mods and races spring has (in all likelihood it would be hard to get a good model even for much simpler RTSes like starcraft, but it's feasible).

Also I've never actually tried reading spring replays with programs, but I'm not sure if it even has information in proper format - a sad fact about starcraft was that the only available replay loaders weren't giving just successful build unit orders, but also ones that weren't accepted as valid, so basically you'd get 50 clicks of a nervous person trying to build a Probe without enough minerals.

Oh... look, I went offtopic, oh well.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Headless Spring?

Post by AF »

Some of sander bakkes students used java written genetic algorithms to generate NTai configs, run a battery of tests to determine which ones were best, then regenerated them and reran the tests.

Things werent entirely stable back then, but it should be possible to write a much faster more efficient and flexible version using Shard instead as you would be able to directly program in the genetic algorithm rather than use an external program or write a new AI from scratch.

The trick is that instead of assigning a tasklist to a unit that is a table array of unitnames in strings, you would assign it a function that returned that array, from which you can return your tasklist youve generated via the genetic algorithm, then use your own behaviours to determine how succesful it was.
SiriusDragon
Posts: 14
Joined: 21 Mar 2010, 07:13

Re: Headless Spring?

Post by SiriusDragon »

Hey all,

Thanks for the replies, I apologise for not replying sooner.

I've been trying to use GA's and NNs or similar techniques basically to help make an AI learn the game, as opposed to being scripted.

Now, I know all the performance arguments and other such stuff but the problem of sorts is that my tutor/mentor basically reckons I should be able to do the AI this way so he's been poking me in this direction.

It's great from a theoretical perspective, but it's proving hard to implement and hard to investigate :(

My previous AI was the complete opposite of this intended AI, it was totally scripted and unable to react or change to what players did.

Due to time running out more rapidly than I'd hoped, maybe I'll have to settle for a rearchitecture and polishing of my scripted AI, and deal with more advanced stuff for my next semester...
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Headless Spring?

Post by AF »

Ah supervisors/tutors tend not to realise what is happening or be bothered doing the actual research into whats possible.

e.g. my friend jen was doing a C# project and our supervisor asked her to give him seperate header source files to look over o_0 He also spent a vast amount of time trying to figure out how to say 'NTAI' finally giving up and saying 'entaye'
Post Reply

Return to “AI”