Automating matches between two bots for training

Anything related on how to build / improve your AI using BWAPI, BWTA, BWSAL, etc.
User avatar
Leckofunny
Posts: 27
Joined: Mon Apr 04, 2016 7:41 pm

Automating matches between two bots for training

Postby Leckofunny » Fri Apr 08, 2016 3:33 pm

Hello everybody,

I'd like to discuss the training setup of combat units using artificial neural networks. So here is my goal:

I desire to let two armies fight each other on a map (e.g. 10 marines vs. 10 dragoons) over and over again. This way I'm planning on training the neural nets of the individual combat unit types.


My approach would be to inject two bots using two instances of Starcraft to run network matches. In order to achieve effective training, the match needs to be played lots of times. I fear that just letting one bot fight the original computer won't return reasonable results. The computer just counter attacks and gets baited. This scenario would lead to overfitting of the neural net.


It would be great if some people could share their opinions or experience on this matter. The combat simulator SparCraft seems to be unsuitable, because it doesn't support collisions. The micro management and real movement inside the game is crucial. I imagine units trying to run into each other.
andertavares
Posts: 1
Joined: Mon Apr 04, 2016 10:17 pm

Re: Automating matches between two bots for training

Postby andertavares » Sat Apr 09, 2016 1:18 pm

Maybe the folks of StarCraft Micro AI tournament may help you, try getting in touch with them: http://scmai5-after.mylifeforai.com/
sol_kanar
Posts: 1
Joined: Sat Apr 09, 2016 3:47 pm

Re: Automating matches between two bots for training

Postby sol_kanar » Sat Apr 09, 2016 3:52 pm

Me and my team are also working on machine learning, and so far we found the following solution:
- one "master" virtual machine for the "main" program, and several "slave" VMs
- starcraft tournament manager server running on the "master" VM and tournament manager client on the "slave" VMs
- run several games at once using the tournament manager, and analyze the collected data on the "master" VM

Hope this helps!
User avatar
Leckofunny
Posts: 27
Joined: Mon Apr 04, 2016 7:41 pm

Re: Automating matches between two bots for training

Postby Leckofunny » Mon Apr 11, 2016 6:43 pm

Thanks for the replies.

I just got admission for writing my bachelor thesis. So I'll start working on this concern pretty soon.

This is the Eposé of my thesis.
User avatar
Leckofunny
Posts: 27
Joined: Mon Apr 04, 2016 7:41 pm

Re: Automating matches between two bots for training

Postby Leckofunny » Tue Apr 19, 2016 11:07 am

So it looks like that automating matches with the bwapi.ini is all that's needed.

But I'm running into the issue that both Starcraft instances crash as soon as OnStart() is done (checked with logging).

This is what I'm doing inside OnStart():

Code: Select all

       
        public override void OnStart()
        {
            FileLogUtil.WriteLine("MATCH START");
            Game.EnableFlag(Flag.CompleteMapInformation); // this flag makes the information about the enemy units avaible
            //Game.EnableFlag(Flag.UserInput); // this flag allows the user to take action
            Game.SetLocalSpeed(0); // fastest game speed, maybe adding frame skipping increases game speed
            InitializeSquad(); // instantiate the SquadSupervisor and its units
            isEnemySquadInitialized = false;
            FileLogUtil.WriteLine("ON START DONE");
        }
       


The InitiallizeSquad functions adds all the owned marine combat units to the SquadSupervisor's list. The SquadSupervisor himself is a Singleton and gets initialized (typical GetInstance() call, if instance is null, instantiate the instance) as well.

Now this happens inside OnFrame():

Code: Select all

       
        public override void OnFrame()
        {
            if (!isEnemySquadInitialized && Game.AllUnits.Count > Game.Self.Units.Count)
            {
                InitializeEnemySquad();
                isEnemySquadInitialized = true;
                // ForceAttack test
                squadSupervisor.ForceAttack(Utility.ConvertTilePosition(new TilePosition(29, 27))); // send units to attack some spot between the two armies
                FileLogUtil.WriteLine("ATTACK !!!!!!!!!");
            }
        }
       


There is one clue which changes the behavior:
The boolean 'isEnemySquadInitialized' is initialized as false. If I set this to false again inside OnStart(), Starcraft will crash on the second match. If I don't set it again to false, the second, third, fourth, ... match will commence, but it won't trigger ForceAttack().

Do I have to clean up everything before the next match starts? It feels like that the loaded AiModule is always in scope.



I just logged this behavior about incrementing a variable inside OnStart()

Code: Select all

13:59:43.1076787   MATCH START
13:59:43.1171787   this is x : 1
13:59:43.1191785   ON START DONE
14:00:11.5629197   MATCH START
14:00:11.5659212   this is x : 2
14:00:11.5679194   ON START DONE
14:00:46.8589947   MATCH START
14:00:46.8609938   this is x : 3
14:00:46.8629956   ON START DONE
User avatar
warwolf30
Site Admin
Posts: 7
Joined: Mon Apr 04, 2016 12:33 am

Re: Automating matches between two bots for training

Postby warwolf30 » Tue Apr 19, 2016 1:09 pm

I'm not sure what are you using to program your bot (C++ or Java) or (AIModule or AIClient). But in C++ and AIModule, you don't need to cleanup the variables, since all is destroyed between games, BUT if you are creating an AIClient, you need to cleanup all your variables before the next game.
User avatar
Leckofunny
Posts: 27
Joined: Mon Apr 04, 2016 7:41 pm

Re: Automating matches between two bots for training

Postby Leckofunny » Tue Apr 19, 2016 3:51 pm

I'm using this C# Wrapper. It uses a BroodwarLoader.dll as AiModule to inject a module which inherits from AiBase.
User avatar
warwolf30
Site Admin
Posts: 7
Joined: Mon Apr 04, 2016 12:33 am

Re: Automating matches between two bots for training

Postby warwolf30 » Tue Apr 19, 2016 4:52 pm

Well, I reviewed the code in C# Wrapper, and the wrapper is builded around the BWAPI AI Client version (the README can be misleading). So, yes, you need to clean your variables after each game ;)
User avatar
Leckofunny
Posts: 27
Joined: Mon Apr 04, 2016 7:41 pm

Re: Automating matches between two bots for training

Postby Leckofunny » Tue Apr 19, 2016 9:41 pm

Thanks a lot for your effort.

Working with the same scope through the whole sessions could actually be a pretty nice advantage. Otherwise I'd have to work on some persistent stuff in order to guide the upcoming training procedure.

Return to “AI development (BWAPI Bots)”

Who is online

Users browsing this forum: No registered users and 2 guests