some
[mc1516pa.git] / code / SokobanObjectwise.icl
index 4b9542d..656fad8 100644 (file)
@@ -41,7 +41,7 @@ encode p = join "\n" [
        "--Agent not on the box",
        "INVAR " <+ encodeAgentNotOnBox boxnums <+ ";",
        "--Box not on box",
-       encodeBoxOnBoxes boxnums,
+       "INVAR " <+ encodeBoxOnBoxes boxnums <+ ";",
        "--Goal state",
        "INVAR " <+ encodeGoalState boxnums targetPos <+ ";",
        "--Agent movement",
@@ -116,8 +116,8 @@ encodeGoalState boxes targets = "(" <+
 
 encodeBoxOnBoxes :: [Int] -> String
 encodeBoxOnBoxes [] = ""
-encodeBoxOnBoxes [b] = ""
-encodeBoxOnBoxes [b:bs] = "INVAR " <+ encodeBoxOnBox b bs <+ ";\n" <+
+encodeBoxOnBoxes [b] = "TRUE"
+encodeBoxOnBoxes [b:bs] = encodeBoxOnBox b bs <+ " &\n\t" <+
        encodeBoxOnBoxes bs
        where
                encodeBoxOnBox :: Int [Int] -> String
@@ -129,8 +129,8 @@ encodeAgentNotOnBox bs = join " &\n\t" [
        "!(b" <+ i <+ ".x = agent.x & b" <+ i <+ ".y = agent.y)"\\i<-bs]
 
 encodeObMovement :: String -> String
-encodeObMovement s = "TRANS next(" <+ s <+ ".x) = " <+ s <+ ".x + dx;\n" <+
-       "TRANS next(" <+ s <+ ".y) = " <+ s <+ ".y + dy;"
+encodeObMovement s = "TRANS next(" <+ s <+ ".x) = " <+ s <+ ".x + dx & " <+
+       "next(" <+ s <+ ".y) = " <+ s <+ ".y + dy;"
 
 encodeObPosition :: [(Int, Int)] -> String
 encodeObPosition p = join " |\n\t" [forThisX x p\\x<-removeDup $ map fst p]