我正在尝试制作类似于扫雷的游戏,并且我正在尝试计算地图上某个点附近的炸弹数量,但它只进入一个 countneighbour 并且它停止了,我怎样才能让它进入其他 countneighbor 谓词?
checkneighbours(X,Y) :- nb_setval(vecini,0),
X1 is X-1,
X2 is X+1,
Y1 is Y-1,
Y2 is Y+1,
countneighbours(X1,Y),
countneighbours(X1,Y1),
countneighbours(X1,Y2),
countneighbours(X,Y1),
countneighbours(X,Y2),
countneighbours(X2,Y1),
countneighbours(X2,Y),
countneighbours(X2,Y2),
nb_getval(V,vecini),
write(V).
countneighbours(X,Y) :- map(X,Y,Z),
( Z=:= "O"
-> nb_getval(V,vecini),
V1 is V+1,
nb_setval(vecini,V1)
).