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.

No comments:

Post a Comment