-checkX :: Int -> Int
-checkX x = let (Sokoban p) = puzzle in if (x > length (hd p)) (-1) x
-
-checkY :: Int -> Int
-checkY y = let (Sokoban p) = puzzle in if (y > length p) (-1) y
-
-genField :: SokobanPuzzle -> [String]
-genField p = let (Sokoban pzl) = p in genField` pzl 0 0 []
-where
- genField` :: [[SokobanTile]] Int Int [String] -> [String]
- genField` p i j rs
- | i+1 == length (hd p) = rs
- | j == (length p) = genField` p (i+1) 0 [" init(x" +++ toString i +++ "_" +++ toString j +++ ") := " +++ fromTile ((p !! i) !! j) +++ ";\n": rs]
- | otherwise = genField` p i (j+1) [" init(x" +++ toString i +++ "_" +++ toString j +++ ") := " +++ fromTile ((p !! i) !! j) +++ ";\n": rs]
-
-genVars :: Int Int -> [String]
-genVars x y = genVars` x y 0 0 []
-where
- genVars` :: Int Int Int Int [String] -> [String]
- genVars` a b x y res
- | (a+1) == x = res
- | b == y = genVars` a b (x+1) 0 [" x" +++ toString x +++ "_" +++ toString y +++ " : {Wall, Free, Box, BoxOnTarget, Target, Agent, AgentOnTarget};\n":res]
- | otherwise = genVars` a b x (y+1) [" x" +++ toString x +++ "_" +++ toString y +++ " : {Wall, Free, Box, BoxOnTarget, Target, Agent, AgentOnTarget};\n":res]
-
-genCoord :: Int Int -> [String]
-genCoord x y = [" next(x" +++ toString x +++ "_" +++ toString y +++ ") := case\n",
+checkY :: [[SokobanTile]] Int Int -> Int
+checkY p x y = let (Sokoban p) = puzzle in if (y > (length (p !! x) - 1)) (-1) y
+
+genField :: [[SokobanTile]] Int Int -> String
+genField p x y = " init(x" +++ toString x +++ "_" +++ toString y +++ ") := " +++ fromTile ((p !! x) !! y) +++ ";\n"
+
+genVars :: Int Int -> String
+genVars x y = " x" +++ toString x +++ "_" +++ toString y +++ " : {Wall, Free, Box, BoxOnTarget, Target, Agent, AgentOnTarget};\n"
+
+genCoord :: [[SokobanTile]] Int Int -> [String]
+genCoord p x y = [" next(x" +++ toString x +++ "_" +++ toString y +++ ") := case\n",