X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=code%2FSokobanObjectwise.icl;h=656fad8312292a46978193aad47dc031f358488b;hb=59b2b66a7c7b6585ebd30e8c530b9f826bcc70e9;hp=6c65c6d25b19c147beaf933ed3ee37d135bb2bd3;hpb=8befabf960165fe8c3ce6b1dfd280bf6d7500766;p=mc1516pa.git diff --git a/code/SokobanObjectwise.icl b/code/SokobanObjectwise.icl index 6c65c6d..656fad8 100644 --- a/code/SokobanObjectwise.icl +++ b/code/SokobanObjectwise.icl @@ -41,11 +41,12 @@ encode p = join "\n" [ "--Agent not on the box", "INVAR " <+ encodeAgentNotOnBox boxnums <+ ";", "--Box not on box", - encodeBoxOnBoxes (indexList boxes), + "INVAR " <+ encodeBoxOnBoxes boxnums <+ ";", "--Goal state", "INVAR " <+ encodeGoalState boxnums targetPos <+ ";", - "", + "--Agent movement", encodeObMovement "agent", + "--Box movement", encodeBoxMovement boxnums, "CTLSPEC ! EF (movement = finished);", @@ -115,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 @@ -128,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]