Smilenet & Unity

The engine.
Post Reply
Skipla
Posts: 5
Joined: Sat Mar 14, 2015 12:50 pm

Smilenet & Unity

Post by Skipla »

Hi
I'm having issues adding smilenet.dll as plugin to Unity game engine
I'm using Unity 5.6.0 it should be as simple as just adding the file under the "..Assets" folder in unity or even and "..Assets.Plugins". But Unity says it cannot find the namespace "Smile".
I have used smilenet.dll with visual studio fine and there the namespace "smile" is found fine.

It seems it is just unity that has issues
Here is the unity guide on plugins.
https://docs.unity3d.com/Manual/Plugins.html

I hope you can help
Thanks
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Smilenet & Unity

Post by shooltz[BayesFusion] »

I hope you can help
Unfortunately, none of us here has ever used Unity.

According to the article linked below, using mixed-mode assemblies like Smile.NET is not supported in Unity.
Skipla
Posts: 5
Joined: Sat Mar 14, 2015 12:50 pm

Re: Smilenet & Unity

Post by Skipla »

is there a non-mixed version available?
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Smilenet & Unity

Post by shooltz[BayesFusion] »

is there a non-mixed version available?
No, because SMILE is written in native C++. Smile.NET is an assembly which contains both native SMILE code and the .NET classes in the Smile and Smile.Learning namespaces.
Skipla
Posts: 5
Joined: Sat Mar 14, 2015 12:50 pm

Re: Smilenet & Unity

Post by Skipla »

The reason I ask is that from version 5 unity should work fine with managed and native libraries, (e.g. C++ etc). I'm not after Smile Learn, I'm only using Smile, I don't particularly need a whole package of some sort.
I'm using this for my PhD project, I had it working in another environment that worked fine but I have since lost that environment and am being asked to show how my engine for games that uses Bayes nets can be used in an actual game.
The easy access to that is through Unity.

So really is there a DLL with just smile C++ in it or is it possible to compile it?
Really all I use is as follows:

Code: Select all

[code]
using Smile;

namespace Assets.Gamelogic.AI
{
    public class Bayes : Smile.Network
    { 
    .....
    AddNode(...)
    SetNodeName(...)    
    SetNodePosition(...)
    AddOutcome(...)
    SetNodeDefinition(...)    
    AddArc(..)
    UpdateBeliefs()
    etc.
    ...
        
 
[/code]

If it is possible to get this basic functionality as a native DLL file then Unity reads it in as a sort of object and allows me to use it in C# "scripts" by referencing as if it is a namespace.
It does not need to be compatible for .NET, unity is completely independent of .NET, it just uses C# as a scripting language. By this, I mean that in order to get a specific functionality for an object in the game, you just add a C# file to it and in the C# code you can call other objects in the game.
The unity engine patches it together.
I hope this helps explain what I need.

I also hope you can help with this as I need to rebuild/develop all of my engine in this new environment in order to satisfy examiners requests for my PhD dissertation.(when I say "need", I mean that the alternative of hacking my own UI in order to demonstrate the game applicability will be very time consuming etc and I have limited time and resources.)

I do aim for it to be part of a commercial game in the future which obviously would then mean the I would buy a licence from you guys :)
That is still only a hopeful intention though, one thing at a time.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Smilenet & Unity

Post by shooltz[BayesFusion] »

So really is there a DLL with just smile C++ in it or is it possible to compile it?
There's no DLL with SMILE that we offer. You'll need to download the static SMILE library for the compiler you have and create the DLL yourself.

Unity's documentation simply says that you need to export the DLL functions as extern "C" without C++ name mangling.
https://docs.unity3d.com/Manual/NativePlugins.html
Skipla
Posts: 5
Joined: Sat Mar 14, 2015 12:50 pm

Re: Smilenet & Unity

Post by Skipla »

I followed your advice and built an interface, i.e. my own dll using the .lib and h files.
That worked fine, Thanks.

Now I have actually switched to just using C++ for all the AI.
This is because of the server setup, that I'm using, is Spatial OS which is an operating system that provides a seamless virtual world that is running on multiple servers by preserving a centralised state and distribute processing across multiple servers. This is provided by company Improbable https://improbable.io/
This means that I can keep Unity and the AI in separately compiled applications called workers that share central persisted objects called Entities.

I'm currently only doing this for my PhD major revision, which I need to submit by May 2019.
There is no commercial or non-academic use at present.

I do intend to go commercial and I have read your licence conditions.
When (IF) I do manage to start converting this to an actual commercial product then I will start the conversation with you guys to get a commercial licence.
Post Reply