Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing (nb_)setarg/3 with gnu.prolog in Java
    text
    copied!<p>I'm currently trying to use prolog out of java using gnu.prolog (<a href="http://www.gnu.org/software/gnuprologjava/" rel="nofollow noreferrer">http://www.gnu.org/software/gnuprologjava/</a>).</p> <p>Thanks to the great help of <a href="https://stackoverflow.com/users/874024/capellic">CapelliC</a> I now have a prolog program which works perfect for my purpose. The problem is that gnu.prolog does not support <code>reverse/2</code> nor does it support <code>nb_setarg/3</code>. Java will throw an error:</p> <pre><code>Exception in thread "Game" java.lang.IllegalArgumentException: The goal is not currently active </code></pre> <p>It isn't a big issue to implement <code>reverse/2</code> on my own but I have no idea how to replace <code>nb_setarg/3</code> (<code>setarg/3</code> also doesn't work)</p> <p>Here is my prolog code:</p> <pre><code>findPath(_Limit, [Goal | Rest], Goal, Temp, Temp, [Goal | Rest]) :- !. findPath(Limit, [A | Rest], Goal, Cost, Temp, Path) :- path(A,B,C), \+member(B, Rest), NewCosts is (Temp + C), NewCosts &lt; Limit, findPath(Limit, [B, A | Rest], Goal, Cost, NewCosts, Path). searchPath(Start, Goal, Path_to_goal) :- S = path_len([], 50), repeat, arg(2, S, Limit), ( findPath(Limit, [Start], Goal, Cost, 0, Path) -&gt; ( Cost &lt; Limit -&gt; nb_setarg(1, S, Path), nb_setarg(2, S, Cost), fail ) ; true ), arg(1, S, Rev), reverse(Rev, Path_to_goal). </code></pre> <p>I tried to use <code>JPL</code> from <code>SWI Prolog</code> but I wasn't able to run it because of severel exceptions pointing out, that Eclipse wasn't able to find the library correctly. I always get one of the following Exceptions:</p> <pre><code>Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpl in java.library.path UnsatisfiedLinkError: D:\Program Files\Prolog\bin\jpl.dll: Can't find dependent libraries SWI-Prolog: [FATAL ERROR: Could not find system resources] </code></pre> <p>Even after following <a href="https://stackoverflow.com/questions/9751357/jpl-swi-prolog-not-working">this</a> and <a href="https://stackoverflow.com/questions/12283471/jpl-swi-prolog-configuration-failure">this</a> guide I wasn't able to resolve my problems. Neither on Windows (32bit) nor on Ubuntu (64bit).</p> <p>Do you have an solutions for me how I can either get <code>JPL</code> running or how to be able to use <code>nb_setarg/3</code>? Up to now I spent one and a half days without any results. Quite frustrating...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload