I made a specific yet advanced game playing AI but I want to bring it to D to make it cross platform

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 31 02:29:42 PST 2015


On 31/12/15 11:20 PM, Gan wrote:
> I've written an AI to play a game in Objective-C on Mac. The AI bits are
> mostly C++ code for performance. I want to make the AI cross platform
> because the game has a huge windows user base. My hope is to get other
> programmers interested in helping out because it is very time consuming
> to make perfect screen detection and AI decisions.
>
> My question is, to write the Mac and Windows specific code in their
> respective languages(C# and Obj-C) for UI, screen capture and input
> simulation; can I have that code be usable from D? I don't know much
> about shared libraries or importing DLLs so I have no knowledge on the
> possibility. I would like to write all the AI code in D but have all the
> OS specific code written in their own languages that I can call from D.
> I am very familiar with writing C#, Obj-C and even D code. I just don't
> know how to make them all play nice. Maybe there's a way to compile the
> OS specific code in libraries and D can call them depending on which OS
> the D code gets compiled to?
>
> Would anyone know how to do this? Or have basic examples?
> To start I'd just like to write a D program that can call some specific
> already compiled C# or Obj-C code that will create a UI window but
> maintain full control in D such that D could issue further already
> compiled commands. Also receive input, like a button is clicked and that
> button sends an event notifier back to D.
>
> Is this plausible?

I'll start out by saying, this is more appropriate for D.learn not the 
main D Newsgroup.
What you have here is two separate issues.

- Interacting with Objective-C which over the next few years will become 
very easy (WIP currently). Otherwise you can interact with it via extern(C).
- Interacting with C#. This will be a good deal harder, but still 
do-able with the help of extern(C). You'll need to get good at 
interacting with unmanaged code from there, which I cannot help with 
since it is C# specific.

One thing to remember D is a native language meaning an exe cannot be 
ran on Linux and vice versa.
It won't be as simple as compiling as a shared library once and using it 
everywhere.


More information about the Digitalmars-d mailing list