错误:=:= / 2:参数没有充分实例化

时间:2013-05-28 02:27:08

标签: prolog instantiation-error

所以我断言游戏地图/ 3的值为'O'游戏地图(X,Y,'O'),X和Y从1到10,我在此代码V2=:= "O"得到此错误,如果其中一个V值不是'O',任何人都可以帮忙吗?一切都是实例化但我在调试器中看到,如果值与'O'不同,它会回滚到游戏地图(X,Y,V)并可能删除值或其他东西,我该怎么做才能阻止它,我想要所以,如果值不是'O',则检查其他比较不进行回滚。

 Z=:=3 ->
          (
          random_between(3,8,X),
          random_between(3,8,Y),
          gamemap(X,Y,V),
          V=:="O" ->
          (
          X1 is X-1,
                  X2 is X+1,
              Y1 is Y-1,
          Y2 is Y+1,
          Y3 is Y+2,
          Y5 is Y-2,
          X3 is X+2,
          X5 is X-2,

          gamemap(X1,Y,V1),
          gamemap(X,Y2,V2),
          gamemap(X2,Y,V3),
          gamemap(X,Y1,V4),
      gamemap(X,Y3,V5),
      gamemap(X3,Y,V7),
      gamemap(X,Y5,V9),
      gamemap(X5,Y,V11),

          V2=:= "O", V5 =:="O" ->
         (
             change_map(X,Y2,"O","X"),
                 change_map(X,Y3,"O","X")
         );
         V3=:="O", V7=:="O" ->
         (
                     change_map(X2,Y,"O","X"),
                 change_map(X3,Y,"O","X")
         );
         V4=:="O", V9 =:="O" ->
         (
                     change_map(X,Y1,"O","X"),
                 change_map(X,Y5,"O","X")
         );
         V1=:="O", V11=:="O" ->
         (
                     change_map(X1,Y,"O","X"),
                 change_map(X5,Y,"O","X")

         );
         placeship(3)
         );
      placeship(3)
      )

1 个答案:

答案 0 :(得分:0)

不确定它是否会纠正您的问题,但您的程序缩进与您的括号使用不符。我会按照SWI-Prolog IDE提出的样式缩进来编写

(   (V2=:= "O", V5 =:="O")
->  change_map(X,Y2,"O","X"),
    change_map(X,Y3,"O","X")
;   (V3=:="O", V7=:="O")
->  change_map(X2,Y,"O","X")
...