archive by month
Skip to content

MCRS and TorchCraftAI

We interrupt your regularly scheduled AIIDE analysis for software releases that you may want to know about. These are both under MIT license, meaning the main requirement is that you pass along the license file if you include the code.

MCRS combat simulator library

MCRS is a combat simulator by Christian McCrave, author of McRave. My latest info is that it should be considered beta quality, not fully tested. It follows a different philosophy than SparCraft and FAP, which ask you to provide sets of friendly and enemy units and then simulate a fight with all the units. MCRS wants to know all the visible units all the time—friendly and enemy, every frame. Optionally, you can also inform it of a friendly unit’s target unit, telling it more about the bot’s intentions. When it’s time to simulate a combat, you say how long a simulation you want and pick out one of your units as the seed of the engagement. MCRS figures out for itself which friendly and enemy units should be involved. I gather that it is intended to work well for short durations only: “Do I gain if I fight right now?” not “Will I eventually win this fight if I pour it on?”

Here is the output struct you get back from a simulation. There’s missing capitalization in attackGroundasGround, a sign of the beta status. Scanning through the code, I see that it doesn’t do what I would call a simulation—there are no nested loops—it’s more of a strength comparison. That means it should be quite fast. Personally, I would call it a combat estimator instead of a combat simulator.

struct MCRSOutput {
	double attackAirAsAir = 0.0;
	double attackAirAsGround = 0.0;
	double attackGroundAsAir = 0.0;
	double attackGroundasGround = 0.0;
	bool shouldSynch = false;
}

Without documentation, I’m n0t entirely sure what this is supposed to mean. I’m guessing that the doubles tell you whether it is better to shoot enemy ground units first, or enemy air units. shouldSynch I guess means that, if true, your air and ground units should do the same thing: Both attack or both run away. That sounds useful!

The estimate takes into account DPS, HP, and armor including upgrades, the time to reach engagement range, and high/low ground. It recognizes some spell effects; for example, it knows that a unit under maelstrom can do nothing. But there is no provision for most spell effects. There are adjustments for splash damage, including protoss high templar but not zerg devourers. I don’t see any attempt to understand cloaked units and detection; that might be the biggest missing point.

aWeaponCooldown() looks wrong. It usually returns an air weapon cooldown duration, but for high templar and suicide unit types instead returns a damage amount. Hmm, but a long cooldown means that the unit will not attack again during the simulation, so I think it should work correctly that way. It’s still odd. Also, infested terrans can only attack ground, so that detail looks wrong too. Continuing, I see spider mines being given a ground strength of 0.0. Are those handled by some other means?

Is MCRS a good idea? That depends on how well it works in your bot! Since it behaves differently than other combat simulators, if you already use one then to switch to MCRS you need to revamp your decision making. I haven’t tried it myself, so I can’t speak to how accurate it is... but you could watch McRave play.

TorchCraftAI framework from CherryPi

TorchCraftAI (front page with big tutorial links and small other links) builds on TorchCraft to provide a machine learning framework for Brood War bots. TorchCraftAI is a framework, not a library. You don’t include it as part of your bot, you include your bot as part of it: You take it as a starting point and build your bot inside it by adding pieces and training machine learning models.

As a full framework, TorchCraftAI is big and complex. The high level documentation looks pretty good, but it is not deep; you will probably have to learn a lot by looking around. Apparently the machine learning stuff uses CUDA for both training and play, so it requires an invidious, I mean NVIDIA GPU due to successful proprietarianization of the community. There are instructions for Windows, Linux, and OS X, but I gather that Linux is TorchCraftAI’s native environment, and life should be easier there. There is way more stuff than I can dig into for this post, so that’s enough for now.

TorchCraftAI includes code for CherryPi. It looks as though CherryPi’s learned data files are optional, but “recommended”; they have to be downloaded separately (see instructions under Getting Started). You’ll need CUDA to use them. As I mentioned at the start, it’s MIT licensed, so if you want, you can fork CherryPi and start from there.

Trackbacks

No Trackbacks

Comments

McRave on :

Yay! MCRS is definitely beta still, you're mostly correct on everything you touched on, so I'm glad it's mostly readable!

Targets are unfortunately required not optional. I measure how far a unit is from his target and estimate how long until the unit is in range. I keep all units stored, I just want most recent information always.

The output struct is the simulated values you should use based on what your units are doing. ShouldSynch tells the user if we included air and ground units in the simulation because they will be within proximity. Each simulation value is the action of the unit and whether it's a good idea. It's extremely hard to explain in words without flooding this comment section, this is probably the best way of explaining these 4 values:

https://github.com/Cmccrave/MCRS/blob/master/Source/MCRS.cpp#L101

Goal: be able to make any decision we want without throwing away units because 1 simulation value said "go".

The maths one is kind of a funny one. For now I just made an estimate that didn't make the suicide or spellcaster units broken. It'll be adjusted more in the future!

I'd love to see people compare MCRS and FAP. I've been told McRave is great in open field fights purely because I can snipe units. This is all done through the simulated values!

Tully Elliston on :

MCTS sounds like a superior tool for large-army decision making as it's output sounds less prone to the massive variance of the output of combat sims. FAP still sounds more useful for understanding the outcome of micro conflicts (can these 3 zergling beat this zealot). It would be cool to use both within one bot, for these respective kinds of check

syhw on :

You do not need CUDA if you don't mind being a bit slow. How much is "a bit"? At run/play/evaluation time, for the Building Placer (BP), you'll time out soon enough with the tournament manager. There is probably an easy path to distill or directly reduce the BP model to be able to run in real-time on CPU. For the Build Order Switching model, with a beefy CPU (Skylake and above, not underclocked), you should be able to run in real-time on CPU.

It's for training that things get complicated, at you want to run many games in parallel, the "slowness" adds up, and batching on GPU is quite efficient.

You can still train small models on CPU, e.g. with the micromanagement tutorials, there is are entire families of models that can be explored and trained on CPU only. For instance, https://arxiv.org/abs/1609.02993 was all done on CPU.

MicroDK on :

So you CUDA is not a requirement, only optional? That is good. Next year we will see a flood of CherryPi clones! :D

McRave on :

Possibly, but creating models and training them is harder than pressing "git clone" on Locutus.

Jay Scott on :

It can play without any models. I’m curious to see whether people are put off by its heavyweight nature. Maybe the big Chinese teams will jump on it... but if so, they’d better allow more than 6 weeks.

syhw on :

Yes it can play without models. The codebase is "large", but IMHO it's easy enough to only change one module and forget about the rest, so you can explore doing something rule-based differently over a weekend or two.

Orthogonally, what I really hope we're helping the community with, other than another Locutus-clone-war, is a way to get started with reinforcement learning through a few things:
- the tutorials should help people get started,
- pre-training models on bot data (made easy with TorchCraft) or StarData ( https://github.com/TorchCraft/StarData ) can make the RL training much faster
- the micromanagement scenarios include things that can be trained on a desktop in a few hours of RL training (vs. days on a cluster for the larger stuff, and not everybody has access to a cluster),
- the ability to train "just a module" and see the impact by playing full games with the bot, should be a motivation that the RL experiments are not done in a vacuum.

We tried to put emphasis on that, any feedback about how to make tutorials clearer, or how to make "beefy-desktop +

syhw on :

My comment was cut short!?

I was concluding by: any constructive feedback on how we can lower the barrier of entry to RL even more is super welcomed. :-) And that a GPU should not be necessary, but at some experimental scale (complexity of the scenarios, of the models), you need some TFLOPS, and a GPU with a 16+ cores CPU (to play a lot of games in parallel) is gonna help.

MarcoDBAA on :

I think what we see is somewhat ridiculous.

Professional teams consisting of many people using existing highly functional top bots as base, just to win a competition.

Mostly they also do not develop the bot much further and some of them just use another one as base next year.

Which employer thinks that this is really an achievement?
Well, you probably can promote n-th place in a competition somewhere, if n is high enough...

All of this might not be (or is probably not) the fault of the developers, but of their bosses, which do not want to reserve more work time for this (or do not need to, because clones already place high enough).

I rather see some weaker bots, that are also defeatable for new people uploading their completely self made bots, than bots like "Chimerabot" for (a new) example.

Really hoping that top 16 in SSCAIT won`t be the Clone Wars. Clones are not very impressive, and you must not be very proud :P Hope that the organisers will be restrictive this year. And I say that as a watcher (even though I can only watch replays because of my internet) and not a competitor, that has an interest here.

Tully Elliston on :

Roll on anti-clone rules for future tourneys 100%, surely we are all tired of the Locutus collective by now

MarcoDBAA on :

Ok, when I read again what I said...

It is a bit premature to already complain about the next clone army (the CherryPis, that´s why I posted this here), before it exists, but there are reasons to expect them.

Would rather see one of the cactus bots for example in the top 16 than all these existing and expected clones. Its author still has to improve it (one of them) of course until the deadline, even without old and new clones existing. But if this will be like AIIDE or worse it will be nearly impossible to do (for him and others), while others more or less "git clone" (like McRave said).

McRave on :

Odd to come back to comment on this I know, but I changed the name to Horizon, as it seems a bit easier to remember.

https://github.com/Cmccrave/Horizon

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.