在Prolog中收集回溯解决方案

在Prolog中收集回溯解决方案,prolog,Prolog,我在Swi prolog中收集回溯解决方案时遇到问题,因此我的代码是: fxd_cell(1,1,2). fxd_cell(1,3,7). fxd_cell(1,4,3). fxd_cell(1,6,1). fxd_cell(1,8,8). fxd_cell(2,2,5). fxd_cell(2,4,6). fxd_cell(2,5,2). fxd_cell(2,6,9). fxd_cell(2,9,4). fxd_cell(3,1,3). fxd_cell(3,2,6). fxd_cell(3

我在Swi prolog中收集回溯解决方案时遇到问题,因此我的代码是:

fxd_cell(1,1,2).
fxd_cell(1,3,7).
fxd_cell(1,4,3).
fxd_cell(1,6,1).
fxd_cell(1,8,8).
fxd_cell(2,2,5).
fxd_cell(2,4,6).
fxd_cell(2,5,2).
fxd_cell(2,6,9).
fxd_cell(2,9,4).
fxd_cell(3,1,3).
fxd_cell(3,2,6).
fxd_cell(3,3,9).
fxd_cell(3,6,4).
% snip
fxd_cell(9,7,4).
fxd_cell(9,9,2).


index(_,_).
get_num(X) :- L=[1,2,3,4,5,6,7,8,9], member(X,L).
isEmpty([]):- 1 = 1.
isEmpty([H|_]):- \+ get_num(H),!.

find_Empty(L):-  fail .
find_Empty(L):- get_num(X),get_num(Y),findall(Num,fxd_cell(X,Y,Num),L1),isEmpty(L1),L=        [index(X,Y)|LL].
当我调用find_Empty(L)时,结果将显示为:

L = [index(1, 2)|_G3978] 
当我按下“;”键时,另一种解决方案如下:

L = [index(1, 5)|_G3978] ;
L = [index(1, 7)|_G3978] 
如图所示。。
但是我想让L包含所有的解决方案我怎么能做到

使用
findall/3

findall(X, find_Empty(X), L).

使用
findall/3

findall(X, find_Empty(X), L).