Tuesday 25 March 2014

Problem #5: Prolog's "Out of local stack"

 






Description

You're running SWI-Prolog and you get something like the following:

Solution

Within validmove/3 I had the following code:

I was reading that you get this when you're in some sort of infinite loop. I didn't seem to have that problem because removing  the last line would get rid of the error. I resolved it by adding an exclamation mark.


I believe this is because Prolog is trying to unify MvList with an empty list ([]). Since the way I call validmove/3 would always give a non-empty list, Prolog kept trying to backtrack into moves to find an empty list. But since I don't know Prolog, what I just said could all be baloney.

Comments

The joys of Prolog.

Problem #4: Prolog is hiding part of my answer



 


Description

Your answers keep getting truncated with elipses.

Solution

Press "w" to expand it.


 Press "p" to truncate it again.

Comments

N/A

Problem #3: Prolog ignoring a predicate



Description

Prolog seems to be ignoring the second checkForPeriods
 

Solution

Prolog tries the  predicates in the order they're listed! Since the first predicate is still valid when C is 0, it gets used and C goes into the negatives. To solve this I just needed to reorder the two.

Comment

This caused me so many headaches. I was trying to do this, but it kept going negative until it ran out of stack. As you can probably tell, I have no background in Prolog. I'm learning it while I use it to complete this program.

Monday 24 March 2014

Problem #2: "Syntax error: Operator priority clash"



Description

Solution

Replace the comma on the last line with a period.
SWI-Prolog uses the term for illegal sequences of operators. I.e.
a :- b :- c. 
Quoted from: http://www.groupsrv.com/computers/about124076.html 

Comment

Even though I new to Prolog (this is my second program using it), I feel like I'll continue to make this mistake if I ever use Prolog again.

Problem #1: "Prolog-Interpreter /bin/plwin.exe not found. Please configure correctly."

Description

While trying to use SWI-Prolog-Editor the following error appears in the bottom pane:
Prolog-Interpreter /bin/plwin.exe not found. Please configure correctly.

Solution

You should double check to see which version of swi-prolog you installed (32-bit or 64-bit), because swi-prolog editor only works with the 32-bit version. If you tried using the editor with the 64-bit version, you'll get the error described above
Quoted from: http://stackoverflow.com/a/4811337


Comments

N/A