I'm trying to understand this code for tic tac toe in prolog. I'm able to compile the code in gprolog,
| ?- ['/**/**/**/tictactoe.pl'].
compiling /**/**/**/tictactoe.pl for byte code...
/**/**/**/tictactoe.pl compiled, 142 lines read - 11825 bytes written, 12 ms
(2 ms) yes
but when I'm executing play
, I'm getting the following error:
| ?- play.
uncaught exception: error(existence_error(procedure,not/1),play/0)
As you can see in the last line of the code, play
is defined as follows :
play :-not(clear), repeat, getmove, makemove, printboard, done.
And the same code is working perfectly fine in SWI-prolog
When I'm trying to run the prolog file in terminal with either of the following 2 commands
gplc --no-top-level tictactoe.pl
or
gplc tictactoe.pl
I'm getting the following error:
Undefined symbols for architecture x86_64:
"predicate(assert/1)", referenced from:
predicate(getmove/0) in gplcMtKfGg.o
predicate(makemove/0) in gplcMtKfGg.o
"predicate(not/1)", referenced from:
predicate(empty/1) in gplcMtKfGg.o
predicate(different/2) in gplcMtKfGg.o
predicate(play/0) in gplcMtKfGg.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
compilation failed
Replacing assert
with asserta
solved the problem.