我试图在prolog中理解这个code的tic tac toe。 我能够在gprolog中编译代码,
| ?- ['/**/**/**/tictactoe.pl'].
compiling /**/**/**/tictactoe.pl for byte code...
/**/**/**/tictactoe.pl compiled, 142 lines read - 11825 bytes written, 12 ms
(2 ms) yes
但是当我执行play
时,我收到以下错误:
| ?- play.
uncaught exception: error(existence_error(procedure,not/1),play/0)
正如您在代码的最后一行中所看到的,play
定义如下:
play :-not(clear), repeat, getmove, makemove, printboard, done.
同样的代码在SWI-prolog
当我尝试使用以下两个命令之一在终端中运行prolog文件时
gplc --no-top-level tictactoe.pl
或
gplc tictactoe.pl
我收到以下错误:
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
答案 0 :(得分:1)
用assert
代替asserta
解决了这个问题。