NetCore binding for AI script ?

For AI and campaign script related discussions and questions
Post Reply
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

NetCore binding for AI script ?

Post by Vincent »

Hi,

would it be difficult to bind the NetCore (or DotNet/Mono) to wz 2100 AI API ?
DotNet Platform provides several langages used in gamedev and which are usually faster than Javascript.
There's also some bindings to some advanced AI Framework for neural networks (CNTK, and binding to tensor flow, caffe...) and bayesian network. While neural networks are maybe not suited for RTS gameplay bayesian network can be used to model partial knowledge of opponent units/researsh tree.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NetCore binding for AI script ?

Post by NoQ »

  • The main outcome of picking the language is what kinds of people are we attracting to our humble ecosystem. The industry standard for this sort of stuff is definitely lua, so we'd attract experienced modders and game devs if we pick that. By picking javascript we've attracted a lot of newbie programmers (like myself) and some experienced web developers (both are plentiful), but it also means that for now we don't have much machine learning specialists around. If we want to attract neural network people, i might also consider looking into python (which is also used in current AI experiments on Starcraft [1]).
    Spoiler:
  • Out of the existing users, cowboy [2] is much into C#. I, personally, never touched any .NET stuff yet, so i'd most likely stick to javascript when i get back on track, unless the new API would have significant advantages.
  • Current Javascript API function and object bindings are written by hand [3], and you'd probably have to do the same - and there are quite a lot of functions already, and they keep being added. I'm not sure if you'd be able to avoid code duplication. Also you'd need to provide a mechanism for saving and loading script state in savegames.
  • I'm not entirely convinced that the speed of the language itself is a significant problem for AI scripts. In 3.2 we have mitigated large amounts of performance issues by simply providing a more convenient API that, for example, doesn't force the script to iterate on every droid on the field whenever he wants to enumerate all tanks in a particular 10x10 square. With that, i don't have any data that'd say that we spend much execution time in the scripts themselves.
  • Threading would be fun though. If the items that you mentioned (modeling partial knowledge about the opponent, i.e. what i call "adaptation" when i talk about NullBot) could be run in a separate thread (because all they do is math, they don't interact with the game much, and they don't need to work quickly), that could be useful for making the adaptation code heavier and more powerful. I guess we can emulate this with javascript by making a separate scripting engine context (which doesn't provide any APIs apart from sending and receiving data) and running it in a thread, but it sounds like a hack.
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: NetCore binding for AI script ?

Post by Vincent »

Actually the binding could be provide next to the jscript API, not in replacement of the jscript API.

The big benefit of NetCore or DotNet, besides supporting multiple langage, is that it can load and use C Library almost transparently with PInvoke, which means one can use most math lib available without modifying warzone2100 or the script engine.

Python is indeed used in the ML community but I must admit that I didn't find the CPython API very friendly.
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: NetCore binding for AI script ?

Post by NoQ »

In general, i think that you should totally do it if you'd like to use such API yourself or have strong reasons to believe that people would like it.
Actually the binding could be provide next to the jscript API, not in replacement of the jscript API.
Yeah, that'd be totally necessary.
The big benefit of NetCore or DotNet, besides supporting multiple langage, is that it can load and use C Library almost transparently with PInvoke, which means one can use most math lib available without modifying warzone2100 or the script engine.
Hmm. Would it be secure? Like, we're spreading maps with, possibly, built-in mods in a viral manner through multiplayer games, now with an ability to execute arbitrary binary blobs from within maps downloaded from possibly untrusted hosts, how would we deal with various malware maps and mods? C is very hard to sandbox. Even though the AI script is only run on the host (unlike game rules scripts), the guest player can still open the map after the game, and accidentally run the malicious AI script.
Post Reply