Looking to start a C# AI - Approaches?

Looking to start a C# AI - Approaches?

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

Moderators: hoijui, Moderators

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14588
Joined: 17 Nov 2005, 02:43

Looking to start a C# AI - Approaches?

Post by Forboding Angel » 10 Nov 2011, 04:31

He posting this during the db swap and it got deleted. I think he was somewhat disheartened by it, but I still it on my screen via browser history so I thought I would go ahead and repost it:
-------------------------------------------------------------------
Hi

I'm looking to start an AI in C# - i know there have been some in the past, and FA promises me it's possible, but I don't know how. Any ideas? It looks to me like CSAI is the only one made in C# - but it's old and not compatible with current versions of Spring. Is this possible? I assume I'd have to write a wrapper - how would I go about doing this? I have very little experience with Lua, and a bit in Java and C/C++ - but C# is definitely my best language - and I'd love to try to write an AI - particularly for Evolution RTS :)

Any ideas would be appreciated - thanks!

zplizzi
0 x

User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: Looking to start a C# AI - Approaches?

Post by SpliFF » 10 Nov 2011, 05:33

My answer got deleted too.

In summary it was:

1.) C# blows
2.) Mac and Linux users will hate you
3.) http://springrts.com/wiki/AI:CSAIInterface

So yeah, it should be possible for you to rebuild the wrapper using the info on the wiki but it'll probably just be ignored by everyone and fall into disuse like last time.

If you know C++ you'll probably get more value out of learning to use it properly than you will from a C# wrapper. Noboby is going to stop you releasing your own DLL's but expect to fight an uphill battle for getting your interface or AI shipped with Spring.
0 x

User avatar
hoijui
Former Engine Dev
Posts: 4342
Joined: 22 Sep 2007, 09:51

Re: Looking to start a C# AI - Approaches?

Post by hoijui » 10 Nov 2011, 07:53

use Java.
it is the best maintained, feature richest and most comfortable to use AI API we have today. it is also a much nicer language then C++, and you'd get the best support there. writing a wrapper is a very ugly task, and if you are not very proficient in C, C++, your target language and the to-and-from-native interface/API of your target language, you should not even try to do it (everyone that tried so far, failed, and so would you, neo!).
Java AIs also got a huge performance boost with 83.0, plus various other improvements, and there are more in the stove.
of course the Lua AI way is always a viable alternative, depending on your goals and other stuff.
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Looking to start a C# AI - Approaches?

Post by AF » 10 Nov 2011, 14:49

If you must, keep in mind Mono integration has been discussed and would give a means of supporting Linux and OSX, albeit no full support has ever been added
0 x

User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: Looking to start a C# AI - Approaches?

Post by Licho » 10 Nov 2011, 15:15

c# is awesome and its fully endorsed by the largest OS game for this game :)

It runs fine on linux, in fact all springie-type autohosts are c# and run on linux for all these years.

Mono works fine on both linux and mac - especially the pure logic part.
0 x

zplizzi
Posts: 2
Joined: 10 Nov 2011, 01:27

Re: Looking to start a C# AI - Approaches?

Post by zplizzi » 10 Nov 2011, 16:17

Thanks for reposting this, FA :)

I know there's lots of disadvantages to C#, however, it's the only language I am proficient in, and I don't really want to learn a new language for this.

I assume I would have to write an AI Interface for my AI - and I've read that that can be very ugly and painful, so how would I best go about writing one? I know CSAI and it's AI Interface are built for the old AI system - so I probably couldn't leverage that very much. What is the best way to go about creating a C# AI Interface? And how hard would it be? Like I said before, my C++ and Java knowledge is somewhat limited :(

Thanks for all the replies!
0 x

User avatar
AF
AI Developer
Posts: 20669
Joined: 14 Sep 2004, 11:32

Re: Looking to start a C# AI - Approaches?

Post by AF » 10 Nov 2011, 18:54

Luckily for you the syntax is 99.9% the same, and the main parts you'd need to learn would be the AI interface itself.

The only part you'd need really are container classes and string methods, of which the string methods are nearly identical but with different capitalisation, and the container classes work mostly the same way.

As someone who knows both Java and C#, I'd recommend going for Java for an AI as you should be able to build a fully functioning capable Java AI in less time than a C# AI Interface, despite no prior java experience.

Eitherway you're going to have to learn a language, C/C++ for the Interface library, or one of the competing libraries?
0 x

zplizzi
Posts: 2
Joined: 10 Nov 2011, 01:27

Re: Looking to start a C# AI - Approaches?

Post by zplizzi » 11 Nov 2011, 02:39

Ok - I've started on the Java AI. I guess it does make more sense, but I still like C# better as a coding language.. I wish there were a way to do that easily.

I've got the framework for the Java AI set up - the whole NullOOJavaAI thing. I don't really know where to start with the coding of the actual AI, but I guess i'll figure that out :) I just kind of want to know the general structure of the AI before I do much coding.

Thanks for all the tips and advice - and if anyone else is thinking about creating a C# AI interface, I'm definitely interested :)
0 x

User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: Looking to start a C# AI - Approaches?

Post by Licho » 11 Nov 2011, 03:56

Im interested in using C# AI interface..mainly because zero-k has gigantic C# based infrastructure including site, comprehensive tracked unit and game statististc and game hosts.

We could wire extra information into AI easilly, including stuff like player past behavior and weaknesses or we could feed it information about pro-level play on given map.
0 x

User avatar
hoijui
Former Engine Dev
Posts: 4342
Joined: 22 Sep 2007, 09:51

Re: Looking to start a C# AI - Approaches?

Post by hoijui » 11 Nov 2011, 09:49

is all that info stored permanently in C# specific data-storage? or could it basically be used by any AI (thinking of SQL or the like).
0 x

User avatar
Licho
Zero-K Developer
Posts: 3803
Joined: 19 May 2006, 19:13

Re: Looking to start a C# AI - Approaches?

Post by Licho » 11 Nov 2011, 12:23

It could be used by any AI, but autohost and server is C# and it could use shared logic libs in C# or use its remoting features.
(For example springie, zk lobby and zero-k site all use same lib to connect to lobby server or download stuff).

Also automated build and deployment tools are ready for C# and so are the devs.
There is no serious (active programs in use) java development for spring.
0 x

User avatar
hoijui
Former Engine Dev
Posts: 4342
Joined: 22 Sep 2007, 09:51

Re: Looking to start a C# AI - Approaches?

Post by hoijui » 11 Nov 2011, 15:29

i am also a dev ready to help, java wise, and data-wise it is no problem for any of you C# guys to help someone doing a java ai, to make use of the data. i am also more proficient in AI Interface stuff than any of the C# guys around here, and even though there are few java projects in spring land, that are currently actively used by the public, there are quite some around, and even more so do we have java devs around.
0 x

User avatar
ivand
Posts: 134
Joined: 27 Jun 2007, 17:05

Re: Looking to start a C# AI - Approaches?

Post by ivand » 15 Jan 2012, 20:58

Hi!

The only real problem I faced when I tried to make one was that in order to make bidirectional c++/c# binding one had to have few cpp/hpp files parsed. This was the part of work I had almost completed but still failed. I know there are AWK scripts exist which do the job for JavaAI for instance. Anyway I'm so bad with scripts, so If anyone could just catch the idea of AWK script and modify it in a particular way... then the rest is very basic, if not trivial.

And yes approximately year ago I had prototype which worked very well: it was able to pass information from and to engine. And as here http://springrts.com/wiki/AI:CSAIInterface it's possible to unload/reload skirmish AI code on the fly.

Mono binding is a bit more complex stuff, as far as I got it doesn't bring enough fluency (thru available API) like a native approach, still it's possible to create static bindings and I had/have working example.

Let me know if someone is willing to take a part in creation of dotNet or Mono bindings.

//Ivan
0 x

gajop
Moderator
Posts: 3023
Joined: 05 Aug 2009, 20:42

Re: Looking to start a C# AI - Approaches?

Post by gajop » 16 Jan 2012, 11:39

ivand wrote:Hi!

The only real problem I faced when I tried to make one was that in order to make bidirectional c++/c# binding one had to have few cpp/hpp files parsed. This was the part of work I had almost completed but still failed. I know there are AWK scripts exist which do the job for JavaAI for instance. Anyway I'm so bad with scripts, so If anyone could just catch the idea of AWK script and modify it in a particular way... then the rest is very basic, if not trivial.

And yes approximately year ago I had prototype which worked very well: it was able to pass information from and to engine. And as here http://springrts.com/wiki/AI:CSAIInterface it's possible to unload/reload skirmish AI code on the fly.

Mono binding is a bit more complex stuff, as far as I got it doesn't bring enough fluency (thru available API) like a native approach, still it's possible to create static bindings and I had/have working example.

Let me know if someone is willing to take a part in creation of dotNet or Mono bindings.

//Ivan
Even though I'm not a fan of C# code in open source projects, it'd be more than willing to help. I'm no dev, however, I think I got a bit familiar with the awk scripts and did some small edits here and there.

I'm not exactly sure what's not working for you, if you have a working CS AI (AI written in C#, right?).
0 x

User avatar
ivand
Posts: 134
Joined: 27 Jun 2007, 17:05

Re: Looking to start a C# AI - Approaches?

Post by ivand » 16 Jan 2012, 12:45

gajop wrote: Even though I'm not a fan of C# code in open source projects, it'd be more than willing to help. I'm no dev, however, I think I got a bit familiar with the awk scripts and did some small edits here and there.

I'm not exactly sure what's not working for you, if you have a working CS AI (AI written in C#, right?).
Hi! It's great to hear, good news!

First, about your question. A year ago I did everything by hand, what means implementation could have bugs/typos, despite it used to compile well. Secondly, I haven't tried to recompile it nowadays, however I expect it won't compile since a lot could have changed since year ago.

Secondly, the things what need to be done are as follows. The most important files are located here: https://github.com/spring/spring/tree/4 ... /Interface (same on your drive).

As far as I remember (I'm writing from different PC now) the most the most challenging file is https://github.com/spring/spring/blob/b ... Callback.h

AFAIK, current AWK scripts perform direct translation from the c-header file to Java, Python, etc. and this requires direct script modification. As I do think what I'm not the only person who has scratched my head over this file, my proposal'd be that the best we could do is to make an XML file from this c-header.

I'll send you over the desired file later when I get home, but basically I need hierarchical description tree starting with root, next all structures and enums should go, following by enum and structure members. In case of structure members, next level should be function entities, following function parsing: return type, Calling conventions, function name, parameters and types, etc. One year ago I was also storing the each founded comment line.

Using this file I've just briefly described, it'd trivial to generate bindings for any language, including C#. This could be done either with 2nd AWK script or using any programing language.

Please let me know, if you have any questions so far!
0 x

gajop
Moderator
Posts: 3023
Joined: 05 Aug 2009, 20:42

Re: Looking to start a C# AI - Approaches?

Post by gajop » 16 Jan 2012, 14:54

ivand wrote:
gajop wrote: Even though I'm not a fan of C# code in open source projects, it'd be more than willing to help. I'm no dev, however, I think I got a bit familiar with the awk scripts and did some small edits here and there.

I'm not exactly sure what's not working for you, if you have a working CS AI (AI written in C#, right?).
Hi! It's great to hear, good news!

First, about your question. A year ago I did everything by hand, what means implementation could have bugs/typos, despite it used to compile well. Secondly, I haven't tried to recompile it nowadays, however I expect it won't compile since a lot could have changed since year ago.

Secondly, the things what need to be done are as follows. The most important files are located here: https://github.com/spring/spring/tree/4 ... /Interface (same on your drive).

As far as I remember (I'm writing from different PC now) the most the most challenging file is https://github.com/spring/spring/blob/b ... Callback.h

AFAIK, current AWK scripts perform direct translation from the c-header file to Java, Python, etc. and this requires direct script modification. As I do think what I'm not the only person who has scratched my head over this file, my proposal'd be that the best we could do is to make an XML file from this c-header.

I'll send you over the desired file later when I get home, but basically I need hierarchical description tree starting with root, next all structures and enums should go, following by enum and structure members. In case of structure members, next level should be function entities, following function parsing: return type, Calling conventions, function name, parameters and types, etc. One year ago I was also storing the each founded comment line.

Using this file I've just briefly described, it'd trivial to generate bindings for any language, including C#. This could be done either with 2nd AWK script or using any programing language.

Please let me know, if you have any questions so far!
The way it currently works for Java (and I guess it would be similar for C#), is that you have awk scripts that create a C<->Java bridge, called JavaInterface. Those scripts parse a couple of AIS* files, f.e AISCommands.h and AISEvents.h and end up creating some new .c and .h files for exports, and some .java files that call the native functions.
After that, you have another set of awk scripts that create an OO wrapper over that new java interface (parsing the newly created .java files), and you end up with the JavaOOWrapper.
Now I believe that one of those scripts that create the OO wrapper also uses some common awk scripts (common.awk and commonOO.awk f.e) which are also used in the C++ wrapper (not sure about that but it's a good guess), and my assumption is that those common files are to be used in any other OO languages such as python and C#.

If you were to have asked me initially, the whole awk process is a bit messy, and I would've rather created a C++ OO wrapper by hand and then generated other OO wrappers directly from it (still using an awk script or something similar), much like Starcraft AI Interface does it. However, talking to hoijui, it seems that using the C interface as point of origin makes thing such as ABI compliance over different compilers easier, and thus it seems we will keep the double translation mechanisms for now (unless someone comes with a better solution).

As far as using XMLs or any other mechanism to annotate C, I don't think it's really necessary, we've figured how to parse C files, so I'm not sure it would be worth it (we can discuss it further once you post your file). However, it may be good to have the same general OO interface (to describe generated OO classes, methods, enumerations and their hierarchy), so some sort of shared configuration may be favourable (it probably implicitly exists in those shared awk scripts).

I also suggest we do a cleanup of the generated OO code, a lot of classes are useless to the AI dev (most stuff starting with Wrap, Abstract, Stub), or they just shouldn't be in the same package with important things (Unit, UnitDef, Game and similar) - you end up "not seeing the trees from the forest". I'd also possibly move the event-based AI (OOEventAI.java) to the evt package but that's really insignificant.

Code: Select all

META-INF/
META-INF/MANIFEST.MF
com/
com/springrts/
com/springrts/ai/
com/springrts/ai/oo/
com/springrts/ai/oo/AIEvent.java
com/springrts/ai/oo/AIException.java
com/springrts/ai/oo/AIFloat3.java
com/springrts/ai/oo/CallbackAIException.java
com/springrts/ai/oo/EventAIException.java
com/springrts/ai/oo/AbstractOOAI.java
com/springrts/ai/oo/Enumerations.java
com/springrts/ai/oo/IOOAI.java
com/springrts/ai/oo/IOOEventAI.java
com/springrts/ai/oo/OOAI.java
com/springrts/ai/oo/OOEventAI.java
com/springrts/ai/oo/clb/
com/springrts/ai/oo/clb/AbstractCamera.java
com/springrts/ai/oo/clb/AbstractCheats.java
com/springrts/ai/oo/clb/AbstractCommand.java
com/springrts/ai/oo/clb/AbstractCommandDescription.java
com/springrts/ai/oo/clb/AbstractDamage.java
com/springrts/ai/oo/clb/AbstractDataDirs.java
com/springrts/ai/oo/clb/AbstractDebug.java
com/springrts/ai/oo/clb/AbstractDrawer.java
com/springrts/ai/oo/clb/AbstractEconomy.java
com/springrts/ai/oo/clb/AbstractEngine.java
com/springrts/ai/oo/clb/AbstractFeature.java
com/springrts/ai/oo/clb/AbstractFeatureDef.java
com/springrts/ai/oo/clb/AbstractFigure.java
com/springrts/ai/oo/clb/AbstractFlankingBonus.java
com/springrts/ai/oo/clb/AbstractGame.java
com/springrts/ai/oo/clb/AbstractGraphDrawer.java
com/springrts/ai/oo/clb/AbstractGraphLine.java
com/springrts/ai/oo/clb/AbstractGroup.java
com/springrts/ai/oo/clb/AbstractGui.java
com/springrts/ai/oo/clb/AbstractInfo.java
com/springrts/ai/oo/clb/AbstractLine.java
com/springrts/ai/oo/clb/AbstractLog.java
com/springrts/ai/oo/clb/AbstractMap.java
com/springrts/ai/oo/clb/AbstractMod.java
com/springrts/ai/oo/clb/AbstractModParam.java
com/springrts/ai/oo/clb/AbstractMoveData.java
com/springrts/ai/oo/clb/AbstractOOAICallback.java
com/springrts/ai/oo/clb/AbstractOptionValues.java
com/springrts/ai/oo/clb/AbstractOrderPreview.java
com/springrts/ai/oo/clb/AbstractOverlayTexture.java
com/springrts/ai/oo/clb/AbstractPathDrawer.java
com/springrts/ai/oo/clb/AbstractPathing.java
com/springrts/ai/oo/clb/AbstractPoint.java
com/springrts/ai/oo/clb/AbstractResource.java
com/springrts/ai/oo/clb/AbstractRoots.java
com/springrts/ai/oo/clb/AbstractShield.java
com/springrts/ai/oo/clb/AbstractSkirmishAI.java
com/springrts/ai/oo/clb/AbstractSkirmishAIs.java
com/springrts/ai/oo/clb/AbstractTeams.java
com/springrts/ai/oo/clb/AbstractUnit.java
com/springrts/ai/oo/clb/AbstractUnitDef.java
com/springrts/ai/oo/clb/AbstractVersion.java
com/springrts/ai/oo/clb/AbstractWeaponDef.java
com/springrts/ai/oo/clb/AbstractWeaponMount.java
com/springrts/ai/oo/clb/Camera.java
com/springrts/ai/oo/clb/Cheats.java
com/springrts/ai/oo/clb/Command.java
com/springrts/ai/oo/clb/CommandDescription.java
com/springrts/ai/oo/clb/Damage.java
com/springrts/ai/oo/clb/DataDirs.java
com/springrts/ai/oo/clb/Debug.java
com/springrts/ai/oo/clb/Drawer.java
com/springrts/ai/oo/clb/Economy.java
com/springrts/ai/oo/clb/Engine.java
com/springrts/ai/oo/clb/Feature.java
com/springrts/ai/oo/clb/FeatureDef.java
com/springrts/ai/oo/clb/Figure.java
com/springrts/ai/oo/clb/FlankingBonus.java
com/springrts/ai/oo/clb/Game.java
com/springrts/ai/oo/clb/GraphDrawer.java
com/springrts/ai/oo/clb/GraphLine.java
com/springrts/ai/oo/clb/Group.java
com/springrts/ai/oo/clb/Gui.java
com/springrts/ai/oo/clb/Info.java
com/springrts/ai/oo/clb/Line.java
com/springrts/ai/oo/clb/Log.java
com/springrts/ai/oo/clb/Map.java
com/springrts/ai/oo/clb/Mod.java
com/springrts/ai/oo/clb/ModParam.java
com/springrts/ai/oo/clb/MoveData.java
com/springrts/ai/oo/clb/OOAICallback.java
com/springrts/ai/oo/clb/OptionValues.java
com/springrts/ai/oo/clb/OrderPreview.java
com/springrts/ai/oo/clb/OverlayTexture.java
com/springrts/ai/oo/clb/PathDrawer.java
com/springrts/ai/oo/clb/Pathing.java
com/springrts/ai/oo/clb/Point.java
com/springrts/ai/oo/clb/Resource.java
com/springrts/ai/oo/clb/Roots.java
com/springrts/ai/oo/clb/Shield.java
com/springrts/ai/oo/clb/SkirmishAI.java
com/springrts/ai/oo/clb/SkirmishAIs.java
com/springrts/ai/oo/clb/StubCamera.java
com/springrts/ai/oo/clb/StubCheats.java
com/springrts/ai/oo/clb/StubCommand.java
com/springrts/ai/oo/clb/StubCommandDescription.java
com/springrts/ai/oo/clb/StubDamage.java
com/springrts/ai/oo/clb/StubDataDirs.java
com/springrts/ai/oo/clb/StubDebug.java
com/springrts/ai/oo/clb/StubDrawer.java
com/springrts/ai/oo/clb/StubEconomy.java
com/springrts/ai/oo/clb/StubEngine.java
com/springrts/ai/oo/clb/StubFeature.java
com/springrts/ai/oo/clb/StubFeatureDef.java
com/springrts/ai/oo/clb/StubFigure.java
com/springrts/ai/oo/clb/StubFlankingBonus.java
com/springrts/ai/oo/clb/StubGame.java
com/springrts/ai/oo/clb/StubGraphDrawer.java
com/springrts/ai/oo/clb/StubGraphLine.java
com/springrts/ai/oo/clb/StubGroup.java
com/springrts/ai/oo/clb/StubGui.java
com/springrts/ai/oo/clb/StubInfo.java
com/springrts/ai/oo/clb/StubLine.java
com/springrts/ai/oo/clb/StubLog.java
com/springrts/ai/oo/clb/StubMap.java
com/springrts/ai/oo/clb/StubMod.java
com/springrts/ai/oo/clb/StubModParam.java
com/springrts/ai/oo/clb/StubMoveData.java
com/springrts/ai/oo/clb/StubOOAICallback.java
com/springrts/ai/oo/clb/StubOptionValues.java
com/springrts/ai/oo/clb/StubOrderPreview.java
com/springrts/ai/oo/clb/StubOverlayTexture.java
com/springrts/ai/oo/clb/StubPathDrawer.java
com/springrts/ai/oo/clb/StubPathing.java
com/springrts/ai/oo/clb/StubPoint.java
com/springrts/ai/oo/clb/StubResource.java
com/springrts/ai/oo/clb/StubRoots.java
com/springrts/ai/oo/clb/StubShield.java
com/springrts/ai/oo/clb/StubSkirmishAI.java
com/springrts/ai/oo/clb/StubSkirmishAIs.java
com/springrts/ai/oo/clb/StubTeams.java
com/springrts/ai/oo/clb/StubUnit.java
com/springrts/ai/oo/clb/StubUnitDef.java
com/springrts/ai/oo/clb/StubVersion.java
com/springrts/ai/oo/clb/StubWeaponDef.java
com/springrts/ai/oo/clb/StubWeaponMount.java
com/springrts/ai/oo/clb/Teams.java
com/springrts/ai/oo/clb/Unit.java
com/springrts/ai/oo/clb/UnitDef.java
com/springrts/ai/oo/clb/Version.java
com/springrts/ai/oo/clb/WeaponDef.java
com/springrts/ai/oo/clb/WeaponMount.java
com/springrts/ai/oo/clb/WrappCamera.java
com/springrts/ai/oo/clb/WrappCheats.java
com/springrts/ai/oo/clb/WrappCurrentCommand.java
com/springrts/ai/oo/clb/WrappDamage.java
com/springrts/ai/oo/clb/WrappDataDirs.java
com/springrts/ai/oo/clb/WrappDebug.java
com/springrts/ai/oo/clb/WrappDrawer.java
com/springrts/ai/oo/clb/WrappEconomy.java
com/springrts/ai/oo/clb/WrappEngine.java
com/springrts/ai/oo/clb/WrappFeature.java
com/springrts/ai/oo/clb/WrappFeatureDef.java
com/springrts/ai/oo/clb/WrappFigure.java
com/springrts/ai/oo/clb/WrappFlankingBonus.java
com/springrts/ai/oo/clb/WrappGame.java
com/springrts/ai/oo/clb/WrappGraphDrawer.java
com/springrts/ai/oo/clb/WrappGraphLine.java
com/springrts/ai/oo/clb/WrappGroup.java
com/springrts/ai/oo/clb/WrappGroupSupportedCommand.java
com/springrts/ai/oo/clb/WrappGui.java
com/springrts/ai/oo/clb/WrappInfo.java
com/springrts/ai/oo/clb/WrappLine.java
com/springrts/ai/oo/clb/WrappLog.java
com/springrts/ai/oo/clb/WrappMap.java
com/springrts/ai/oo/clb/WrappMod.java
com/springrts/ai/oo/clb/WrappModParam.java
com/springrts/ai/oo/clb/WrappMoveData.java
com/springrts/ai/oo/clb/WrappOOAICallback.java
com/springrts/ai/oo/clb/WrappOptionValues.java
com/springrts/ai/oo/clb/WrappOrderPreview.java
com/springrts/ai/oo/clb/WrappOverlayTexture.java
com/springrts/ai/oo/clb/WrappPathDrawer.java
com/springrts/ai/oo/clb/WrappPathing.java
com/springrts/ai/oo/clb/WrappPoint.java
com/springrts/ai/oo/clb/WrappResource.java
com/springrts/ai/oo/clb/WrappRoots.java
com/springrts/ai/oo/clb/WrappShield.java
com/springrts/ai/oo/clb/WrappSkirmishAI.java
com/springrts/ai/oo/clb/WrappSkirmishAIs.java
com/springrts/ai/oo/clb/WrappTeams.java
com/springrts/ai/oo/clb/WrappUnit.java
com/springrts/ai/oo/clb/WrappUnitDef.java
com/springrts/ai/oo/clb/WrappUnitSupportedCommand.java
com/springrts/ai/oo/clb/WrappVersion.java
com/springrts/ai/oo/clb/WrappWeaponDef.java
com/springrts/ai/oo/clb/WrappWeaponMount.java
com/springrts/ai/oo/evt/
com/springrts/ai/oo/evt/CommandFinishedAIEvent.java
com/springrts/ai/oo/evt/EnemyAIEvent.java
com/springrts/ai/oo/evt/EnemyCreatedAIEvent.java
com/springrts/ai/oo/evt/EnemyDamagedAIEvent.java
com/springrts/ai/oo/evt/EnemyDestroyedAIEvent.java
com/springrts/ai/oo/evt/EnemyEnterLOSAIEvent.java
com/springrts/ai/oo/evt/EnemyEnterRadarAIEvent.java
com/springrts/ai/oo/evt/EnemyFinishedAIEvent.java
com/springrts/ai/oo/evt/EnemyLeaveLOSAIEvent.java
com/springrts/ai/oo/evt/EnemyLeaveRadarAIEvent.java
com/springrts/ai/oo/evt/InitAIEvent.java
com/springrts/ai/oo/evt/LoadAIEvent.java
com/springrts/ai/oo/evt/LoadSaveAIEvent.java
com/springrts/ai/oo/evt/LuaMessageAIEvent.java
com/springrts/ai/oo/evt/MessageAIEvent.java
com/springrts/ai/oo/evt/PlayerCommandAIEvent.java
com/springrts/ai/oo/evt/ReleaseAIEvent.java
com/springrts/ai/oo/evt/SaveAIEvent.java
com/springrts/ai/oo/evt/SeismicPingAIEvent.java
com/springrts/ai/oo/evt/UnitAIEvent.java
com/springrts/ai/oo/evt/UnitCapturedAIEvent.java
com/springrts/ai/oo/evt/UnitCreatedAIEvent.java
com/springrts/ai/oo/evt/UnitDamagedAIEvent.java
com/springrts/ai/oo/evt/UnitDestroyedAIEvent.java
com/springrts/ai/oo/evt/UnitFinishedAIEvent.java
com/springrts/ai/oo/evt/UnitGivenAIEvent.java
com/springrts/ai/oo/evt/UnitIdleAIEvent.java
com/springrts/ai/oo/evt/UnitLifeStateAIEvent.java
com/springrts/ai/oo/evt/UnitMoveFailedAIEvent.java
com/springrts/ai/oo/evt/UnitTeamChangeAIEvent.java
com/springrts/ai/oo/evt/UpdateAIEvent.java
com/springrts/ai/oo/evt/WeaponFiredAIEvent.java
0 x

User avatar
ivand
Posts: 134
Joined: 27 Jun 2007, 17:05

Re: Looking to start a C# AI - Approaches?

Post by ivand » 16 Jan 2012, 15:37

Got your idea. My interface implementation was very terse, no additional "trees in the forest".

I was thinking about the necessity of additional XML layer and I found it worthwhile for two reasons:
1. Clear and simple point of demarcation between interface and language specific stuff
2. Easiness to add the new language support

It's not that critical to have intermediate files, the only complication of not having them is that I will have to tell/write you what actions should be performed in order to create the workable c# files.

Anyway, as promised here are two files. Please let me know what do you think about them.
Attachments
aiscommand.zip
(7.69 KiB) Downloaded 49 times
sskirmishaicallback.zip
(24.01 KiB) Downloaded 66 times
0 x

gajop
Moderator
Posts: 3023
Joined: 05 Aug 2009, 20:42

Re: Looking to start a C# AI - Approaches?

Post by gajop » 16 Jan 2012, 16:16

ivand wrote:Got your idea. My interface implementation was very terse, no additional "trees in the forest".

I was thinking about the necessity of additional XML layer and I found it worthwhile for two reasons:
1. Clear and simple point of demarcation between interface and language specific stuff
2. Easiness to add the new language support

It's not that critical to have intermediate files, the only complication of not having them is that I will have to tell/write you what actions should be performed in order to create the workable c# files.

Anyway, as promised here are two files. Please let me know what do you think about them.
Those files are rather large to read completaly - do you have an xsd perhaps? Anyhow, from what I understand, you seem to be parsing C interfaces and you're creating simple intermediate XML files, your goal being to later use those XML files in all languages, as a point of reference, without having to parse it again specifically.

I guess I can see the reason for it, but it won't make new interfaces trivial though, much of the awk scripts is the actual production of new interfaces/bridges rather than the C parsing, thus I don't think that the couple of lines saved would be worth it.

Btw, can you show your code that you used for the CSAI - the actual C#<->C bridge (both the C# and C/C++ files, even if they're generated or incompatible with the current version), I'm curious to see if I could create some new awk scripts to generate a functional interface, and would like to have a point of reference.
0 x

User avatar
hoijui
Former Engine Dev
Posts: 4342
Joined: 22 Sep 2007, 09:51

Re: Looking to start a C# AI - Approaches?

Post by hoijui » 16 Jan 2012, 16:48

gajop is right in pretty much everything.
i also agree that it is a mess, but ABI compatibility between compilers in C++ is close to impossible, in C it is doable, and we actually achieved it. you can run VS compiled C++ AIs (eg. Shard) on MinGW compiled spring.
the real problem is, that there is no standard for what we are doing here: auto-creating an OO interface that wraps a pimple/purely functional/C-style interface. and as gajop said, this 90+% of the job, and it is the ugly/hard part of the job, not the actual translation into an other language, which is comparatively widely used stuff, and for which we have automatic wrapper generators in many languages (eg. SWIG or the JNA-Generator).
both the SWIG and the JNA generated wrappers of C++ APIs though, have lots of ugliness built in the code the generate (mostly SWIG), and in some cases generate code that is utterly slow (some stuff in JNA).
the only thing i would like to change really, is to use a nice standard for how to define a low level/C-API plus annotations, for which we could generate an OO wrapper in other languages easily.
to do this nicely though, is kind of a super huge task, and ultra frustrating, i could imagine. AWK scripts were chosen, cause .. we do not want perl. ;-)
... and AWK is cross platform, very lightweight, very easy to learn, flexible and fast enough. i asked for alternatives back then, but i got no suggestions, and i still think it is kind of the the optimal solution. it is only bad cause the guy writing the scripts (du di dum...) was not exactly pro when starting, and is probably still not, and cause the whole task is kind of a hack (due to already mentioned absence of a standard).

edit: i like the suggestions of moving some stuff to other (sub-)packages.
0 x

User avatar
koshi
Lobby Developer
Posts: 1058
Joined: 14 Aug 2007, 16:15

Re: Looking to start a C# AI - Approaches?

Post by koshi » 16 Jan 2012, 17:03

After skimming this thread I'd suggest you guys have a look at the pybindgen+(py)gccxml workflow for automatic scanning/generating. Maybe there's sth to learn from / re-use (internal representation of the gccxml parsed stuff?).
0 x

Post Reply

Return to “AI”