CSharp AI Interface
Moderators: hoijui, Moderators
CSharp AI Interface
Hi Spring AI community!
I've created alpha version of subj using modern CPP GlobalAIInterface as backend. Does anyone except me interested in testing\developing such an interface? If so, what is the best way for me to share sources?
P.S. Be aware that spring should be compiled using MSVC and therefore minor source code modification is absolutely necessary (I have ones).
I've created alpha version of subj using modern CPP GlobalAIInterface as backend. Does anyone except me interested in testing\developing such an interface? If so, what is the best way for me to share sources?
P.S. Be aware that spring should be compiled using MSVC and therefore minor source code modification is absolutely necessary (I have ones).
Re: CSharp AI Interface
sounds like the legacy C++ Wrapper
what interface did you use exactly?
did you use any wrapper?
is your code forming a wrapper or an interface?
will it work on linux?
what parts do have to be compiled with MSVC?
(cause the engine everyone will have will be/is compiled with MinGW)
for code sharing, we prefer git, usually hosted at github.com, but does not have to be there of course.. just everyone here knows that already.
what interface did you use exactly?
did you use any wrapper?
is your code forming a wrapper or an interface?
will it work on linux?
what parts do have to be compiled with MSVC?
(cause the engine everyone will have will be/is compiled with MinGW)
for code sharing, we prefer git, usually hosted at github.com, but does not have to be there of course.. just everyone here knows that already.
Re: CSharp AI Interface
The interface i used was the one which has around 630 functions in "struct SAIInterfaceCallback"
I haven't used any wrapper yet. I'm gonna wrap it into something like old AI interface for C++, but written in C#.
Can't say about Linux, I have no linux installed. One might try it.
I've compiled everything with MSVC, but if MinGW build can load functions from MSVC dll, then you only have to compile Interface Proxy with MSVC. Also AI by itself should be build with MSVC of course.
How do I get access into "master\AI\Interfaces" at github
I haven't used any wrapper yet. I'm gonna wrap it into something like old AI interface for C++, but written in C#.
Can't say about Linux, I have no linux installed. One might try it.
I've compiled everything with MSVC, but if MinGW build can load functions from MSVC dll, then you only have to compile Interface Proxy with MSVC. Also AI by itself should be build with MSVC of course.
How do I get access into "master\AI\Interfaces" at github
Re: CSharp AI Interface
The question is do you use .Net or do you embed Mono into the your AI interface.
If you use .Net specific "embedding" (dunno what it is) things, it will not run on Linux (nor Mac OS).
If you want a cross platform AI interface I can help you with Mono. I tried it once a year ago, but well I love my hard drives
.
If you use .Net specific "embedding" (dunno what it is) things, it will not run on Linux (nor Mac OS).
If you want a cross platform AI interface I can help you with Mono. I tried it once a year ago, but well I love my hard drives

Re: CSharp AI Interface
I used .Net classes, but as far as I remember I had experience running .NET code under MONO on FreeBSD, and the code was running well, so I'm not 100% sure that my code won't work under Linux. Anyway I can't see lots of troubles porting the code to Mono, if it has "Reflection" and "Marshaling".Agon wrote:The question is do you use .Net or do you embed Mono into the your AI interface.
If you use .Net specific "embedding" (dunno what it is) things, it will not run on Linux (nor Mac OS).
If you want a cross platform AI interface I can help you with Mono. I tried it once a year ago, but well I love my hard drives.
Re: CSharp AI Interface
I dont know how your AI interface communicates with the C# code.
But "Reflection" and "Marshaling" works under Mono.
If you use Mono you would implement it this way:
AI interface in C/C++ which has the Mono VM embedded.
The AI interface loads the .Net bytecode (dlls) and executes the commands, passes the variables etc. by using "Marshalling".
So you would need to create a script (awk/perl/swig) or a C# "C parser" which uses CodeDom to generate a (C#) Wrapper around the C AI API. Basically the same as the Java AI interface does it.
The C part would require around 1000 lines of code the parser around the half.
For more information about embedding Mono take a look here:
http://www.mono-project.com/Embedding_Mono
http://anonsvn.mono-project.com/viewvc/ ... les/embed/
And my try: http://springrts.com/phpbb/viewtopic.php?f=15&t=16872
You can contact my in the Lobby channel ai .
But "Reflection" and "Marshaling" works under Mono.
If you use Mono you would implement it this way:
AI interface in C/C++ which has the Mono VM embedded.
The AI interface loads the .Net bytecode (dlls) and executes the commands, passes the variables etc. by using "Marshalling".
So you would need to create a script (awk/perl/swig) or a C# "C parser" which uses CodeDom to generate a (C#) Wrapper around the C AI API. Basically the same as the Java AI interface does it.
The C part would require around 1000 lines of code the parser around the half.
For more information about embedding Mono take a look here:
http://www.mono-project.com/Embedding_Mono
http://anonsvn.mono-project.com/viewvc/ ... les/embed/
And my try: http://springrts.com/phpbb/viewtopic.php?f=15&t=16872
You can contact my in the Lobby channel ai .
Re: CSharp AI Interface
Thanks for info.Agon wrote:I dont know how your AI interface communicates with the C# code.
But "Reflection" and "Marshaling" works under Mono.
If you use Mono you would implement it this way:
AI interface in C/C++ which has the Mono VM embedded.
The AI interface loads the .Net bytecode (dlls) and executes the commands, passes the variables etc. by using "Marshalling".
So you would need to create a script (awk/perl/swig) or a C# "C parser" which uses CodeDom to generate a (C#) Wrapper around the C AI API. Basically the same as the Java AI interface does it.
The C part would require around 1000 lines of code the parser around the half.
For more information about embedding Mono take a look here:
http://www.mono-project.com/Embedding_Mono
http://anonsvn.mono-project.com/viewvc/ ... les/embed/
And my try: http://springrts.com/phpbb/viewtopic.php?f=15&t=16872
You can contact my in the Lobby channel ai .
It'd hard to create script which parse "c" files, because "c" files are not clean enough. I almost complete the parser that did the job, but after I encountered several errors during parsing (with commented out functions, etc.), I've decided to stop trying and do it by hand. If the sources from "\ExternalAI\Interface" were more clean and strict, I'd complete my parser-generator.
P.S. How do you debug the code under the MinGW environment. I tried once and it's the real pain (to compare with MSVC IDE).
Re: CSharp AI Interface
You could take a look at the awk script for Java.
But as far as I remember it is really big and complex.
The C AI API code is really good formated with special name tagging and such things to easy the wrapping.
I tried wrapping first with an AWK script but switched to a C# "C-parser" which could output most common .Net languages like C#, VB.Net, Python, Boo.....
I wouldn't do it by hand because every time the API changes you need to correct your wrapper and wrapping a lot of structs is a lot of work.
You are faster with a script than by hand.
But as far as I remember it is really big and complex.
The C AI API code is really good formated with special name tagging and such things to easy the wrapping.
I tried wrapping first with an AWK script but switched to a C# "C-parser" which could output most common .Net languages like C#, VB.Net, Python, Boo.....
I wouldn't do it by hand because every time the API changes you need to correct your wrapper and wrapping a lot of structs is a lot of work.
You are faster with a script than by hand.
Re: CSharp AI Interface
i do parse the C files (both for the Java interface and the new C++ wrapper), and the parsing code is really minimal (around 20-40 lines or so in AWK). it is not hard to ignore commented lines.
of course, debugging with MinGW/GDB is not as comfortable as with MSVC. you could debug stuff in MSVC and when it is bug free there, fix the few remaining things that are MinGW related, if any.
As Agon explained, the interface dll should be written in C/C++.
This is not so much about technical restrictions, but about practical ones. if your stuff will not compile on MinGW under windows and GCC under Linux, it will never be included in spring, and consequently, very few users would ever use it (only the ones that go to the forum and download your interface dll manually plus available C# AIs < 1% of users).
github
you should make a repository for your interface, and then register it as a submodule under /AI/Interfaces/
in more detail:
lets say, your itnerface is called CSharp, so you would have:
master/AI/Interfaces/CSharp/<stuff>
you should make a repository with CSharp as your root, so this would look like: master/<stuff>
and under the spring source, anyone who wants to try your interface can then mount your repository as submodule.
well.. Agon may be able to explain it better, if you see him, or contact me, also in the #ai channel on the lobby.
and yeah...
what Agon said :D
of course, debugging with MinGW/GDB is not as comfortable as with MSVC. you could debug stuff in MSVC and when it is bug free there, fix the few remaining things that are MinGW related, if any.
As Agon explained, the interface dll should be written in C/C++.
This is not so much about technical restrictions, but about practical ones. if your stuff will not compile on MinGW under windows and GCC under Linux, it will never be included in spring, and consequently, very few users would ever use it (only the ones that go to the forum and download your interface dll manually plus available C# AIs < 1% of users).
github
you should make a repository for your interface, and then register it as a submodule under /AI/Interfaces/
in more detail:
lets say, your itnerface is called CSharp, so you would have:
master/AI/Interfaces/CSharp/<stuff>
you should make a repository with CSharp as your root, so this would look like: master/<stuff>
and under the spring source, anyone who wants to try your interface can then mount your repository as submodule.
well.. Agon may be able to explain it better, if you see him, or contact me, also in the #ai channel on the lobby.
and yeah...
what Agon said :D
Re: CSharp AI Interface
I would personally refrain from any usage of mono, or C# code in an OSS project. Especially due to current controversy going about it.
Whats the point anyway? Use java instead, same VM language, but at least more widely accepted.
Edit : especially because spring will loose any chance of being included into debian repos (iirc mono was rejected from debian)
Whats the point anyway? Use java instead, same VM language, but at least more widely accepted.
Edit : especially because spring will loose any chance of being included into debian repos (iirc mono was rejected from debian)
Re: CSharp AI Interface
Oh no! Not again.... Its always the same, you discuss Mono and someone needs to bring up M$ and Mono "controversy".
Btw. Novell and Microsoft are cooperating as it looks like.
And Debian well is Debian, and if they dont want Mono in there repos so be it.
In the end this would be a (sub)module so you can decide if you want to compile it or even have it on your HD or not.
The JVM can run C# code through a lib but dont know how much they have implemented. Also the JVM's bytecode is not the same as the .Net one.
Btw. Novell and Microsoft are cooperating as it looks like.
And Debian well is Debian, and if they dont want Mono in there repos so be it.
In the end this would be a (sub)module so you can decide if you want to compile it or even have it on your HD or not.
The JVM can run C# code through a lib but dont know how much they have implemented. Also the JVM's bytecode is not the same as the .Net one.
Re: CSharp AI Interface
whats the point of adding something written for windows, with a questionable future and security issues, which is being disputed and knocked down here and there, when you can simply choose some VM language which is widely accepted?
Throwing away a chance of getting into debian repo just because "we felt like doing C# instead of XXX" is silly, IMO.
Novell is a kid in the corner for most of the linux community anyway.
Throwing away a chance of getting into debian repo just because "we felt like doing C# instead of XXX" is silly, IMO.
Novell is a kid in the corner for most of the linux community anyway.
Re: CSharp AI Interface
Mono is crossplatform. The security issues are getting fixed if you mean something like accessing files or calling other programs from a embedded VM.
The goal is btw. not getting code into debian repos, the goal is to write C# AIs mainly....
The goal is btw. not getting code into debian repos, the goal is to write C# AIs mainly....
Re: CSharp AI Interface
I was not talking in the OP's topic, but was taking the whole spring project in general.
Effectively :
Bad : spring requires MONO to work
a bit better : spring requires MONO to make one of the AI's to work
OK : spring requires MONO ONLY to code the AI
good : spring does not require mono at all.
Effectively :
Bad : spring requires MONO to work
a bit better : spring requires MONO to make one of the AI's to work
OK : spring requires MONO ONLY to code the AI
good : spring does not require mono at all.
Re: CSharp AI Interface
All are wrong.
The .Net bytecode AI would need a bridge with Mono (which is crossplatform) or .Net only code to communicate with the AI interface which communicates with the spring engine.
Spring would not require Mono.
The .Net bytecode AI would need a bridge with Mono (which is crossplatform) or .Net only code to communicate with the AI interface which communicates with the spring engine.
Spring would not require Mono.
Re: CSharp AI Interface
Agon wrote:All are wrong.
The .Net bytecode AI would need a bridge with Mono (which is crossplatform) or .Net only code to communicate with the AI interface which communicates with the spring engine.
Spring would not require Mono.
Let me define the term I have used :
spring project - a project in the whole, as it is presented to the user. I.e. AI interfaces, bytecode, the renderer, engine, GUI, etc.
Not just the engine,
and hence lets get back to the opinion I have written above

Re: CSharp AI Interface
just to be clear: AI interface wrappers are *completely separate* from the engine. the engine does not depend on them. if someone wants to write an AI in a certain language you don't wish to use, it won't affect you in any way.
Re: CSharp AI Interface
Very funny. I'm absolutely sure that the most spring players run spring from Windows. Windows is installed on 90% of desktop PC. If U like something else it is your right, but don't try to force your will to other 90%.==Troy== wrote:whats the point of adding something written for windows, with a questionable future and security issues, which is being disputed and knocked down here and there, when you can simply choose some VM language which is widely accepted?
Throwing away a chance of getting into debian repo just because "we felt like doing C# instead of XXX" is silly, IMO.
Novell is a kid in the corner for most of the linux community anyway.
Re: CSharp AI Interface
ivand wrote:Very funny. I'm absolutely sure that the most spring players run spring from Windows. Windows is installed on 90% of desktop PC. If U like something else it is your right, but don't try to force your will to other 90%.==Troy== wrote:whats the point of adding something written for windows, with a questionable future and security issues, which is being disputed and knocked down here and there, when you can simply choose some VM language which is widely accepted?
Throwing away a chance of getting into debian repo just because "we felt like doing C# instead of XXX" is silly, IMO.
Novell is a kid in the corner for most of the linux community anyway.
from springlobby statistics about 40% of players are linux players.
Please stop the M$ marketshare bullshit.
Re: CSharp AI Interface
If you don't like it I don't care (c).==Troy== wrote:ivand wrote:Very funny. I'm absolutely sure that the most spring players run spring from Windows. Windows is installed on 90% of desktop PC. If U like something else it is your right, but don't try to force your will to other 90%.==Troy== wrote:whats the point of adding something written for windows, with a questionable future and security issues, which is being disputed and knocked down here and there, when you can simply choose some VM language which is widely accepted?
Throwing away a chance of getting into debian repo just because "we felt like doing C# instead of XXX" is silly, IMO.
Novell is a kid in the corner for most of the linux community anyway.
from springlobby statistics about 40% of players are linux players.
Please stop the M$ marketshare bullshit.
Please don't turn my thread into holywar.