Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
470 views
in Technique[技术] by (71.8m points)

unity3d - Use Prolog with C# (Unity)

I would like to know if there is an "easy" way to call Prolog (preferably SWI-Prolog) code from C# code (in a Unity context).

I have already tried to use the SWI-Prolog - C# interface (source here) however it is not well maintained and I can't make it work with the last version of SWI-Prolog 64 bits (8.2.4 as of today).

I have also seen that it is possible to send information using an SWI-Prolog socket and a C# socket (or Unity Socket) but I can't make it work, and I am not sure using socket is the best idea for the performance.

The only solution working for me was using another "custom" prolog engine : CSharpProlog. This allows me to integrate Prolog code in CSharp files. Yet I would like to use SWI-Prolog if possible, do anyone knows how I can do that ?

question from:https://stackoverflow.com/questions/65945554/use-prolog-with-c-sharp-unity

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From the link you provided, is not apparent that the source is available here. Just try to compile it, to fit your target machine architecture.

I'm trying to generate the interface on Linux, with MonoDevelop, but it's not immediate, will retry later. Meanwhile, you could try on Windows. Probably will be simpler...

edit

Now I had the time to attempt to compile from source in Windows 10 64 bits, and so far it seems to run pretty well. I'm using VisualStudio Community 2017, and after opened the solution (contrib-swiplcsSwiPlCs_git.sln), have defined _PL_X64 in SwiPLcs properties - compilation.

HTH

edit

Have uploaded this repo that shows a simplified usage of SWIPlCs. Note there is a directory (swipl_cs) where I have simply copied (unchanged) the indispensable source files from SwiPlCs. There is a single Prolog file, that computes N-Queens problem solutions (just the first, to keep things as simple as possible) and displays the steps performed by CLP(FD) - thanks to Markus Triska for the original implementation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...