I'm a newbie in prolog and wanted to write wampus AI with prolog + java , trying to do the logic in prolog and GUI in java but im stuck and a very basic level.
basically I have something like this in my knowledge base
parent(john, sarah).
and i want to know who is sarah's parent (parent(X,sarah)) and i just can't because i cant denfine the term sara! i can define terms like
VariableTerm("X"); // for variable
IntegerTerm // for integer
FloatTerm // for float
but there is just not one for sara -string/atom- Term (actually there is and atom but its protected). I fell like i missed something very basic in my online self tutoring. I've gone through gnu for prolog docs several times but i cant find my answer
P.S.: Working on IntelliJ Idea IDE
UPDATE 1:
I moved to swi-prolog (jpl) so i can do my job there but i can't even get the code to run after adding the lib to my java project, fixed like 2 of its errors but it's just 1 error after another (Currently stuck on java: package org.jpl7 does not exist) and google/stackoverflow solutions won't work
What you want is to ask who sarah's parent is by saying
parent(sarah, X)which unifies variable X with the known parent of sarah, which is john. Then you can chain another goal behind that one that asks who is the parent of X in the form ofparent(sarah,X),parent(X,Y).Unification tries to make two terms the same, or it returns false. X = john, so the query becomesparent(sarah,john),parent(john,Y)..Check out this resource on how Unification works: Learn Prolog Now!: Unification