updated sokoban parser
authorMart Lubbers <mart@martlubbers.net>
Mon, 7 Mar 2016 15:02:03 +0000 (16:02 +0100)
committerMart Lubbers <mart@martlubbers.net>
Mon, 7 Mar 2016 15:02:03 +0000 (16:02 +0100)
code/Sokoban.dcl
code/Sokoban.icl

index 631cf7d..c23bf22 100644 (file)
@@ -3,7 +3,7 @@ definition module Sokoban
 from StdString import class toString
 
 :: SokobanPuzzle = Sokoban [[SokobanTile]]
 from StdString import class toString
 
 :: SokobanPuzzle = Sokoban [[SokobanTile]]
-:: SokobanTile = Wall | Free | Box | Target | Agent
+:: SokobanTile = Free | Wall | Box | Target | Agent | TargetAgent | TargetBox
 
 instance toString SokobanTile
 instance toString SokobanPuzzle
 
 instance toString SokobanTile
 instance toString SokobanPuzzle
index 9102bc1..2788930 100644 (file)
@@ -22,6 +22,8 @@ instance toString SokobanTile where
        toString Box = "$"
        toString Agent = "@"
        toString Target = "."
        toString Box = "$"
        toString Agent = "@"
        toString Target = "."
+       toString TargetBox = "*"
+       toString TargetAgent = "+"
 
 parse :: String *World -> (SokobanPuzzle, *World)
 parse fp w
 
 parse :: String *World -> (SokobanPuzzle, *World)
 parse fp w
@@ -48,6 +50,8 @@ parseRow [x:xs]
        '$' = Box
        '@' = Agent
        '.' = Target
        '$' = Box
        '@' = Agent
        '.' = Target
+       '+' = TargetAgent
+       '*' = TargetBox
        ' ' = Free
        _ = abort ("Unknown char: '" +++ toString x +++ "'")
 = ([current:rest], xs)
        ' ' = Free
        _ = abort ("Unknown char: '" +++ toString x +++ "'")
 = ([current:rest], xs)