From: Mart Lubbers Date: Mon, 7 Mar 2016 15:02:03 +0000 (+0100) Subject: updated sokoban parser X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=d16ccad512857e1469e3b3cb7ff28abc6ca8a46a;p=mc1516pa.git updated sokoban parser --- diff --git a/code/Sokoban.dcl b/code/Sokoban.dcl index 631cf7d..c23bf22 100644 --- a/code/Sokoban.dcl +++ b/code/Sokoban.dcl @@ -3,7 +3,7 @@ definition module Sokoban 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 diff --git a/code/Sokoban.icl b/code/Sokoban.icl index 9102bc1..2788930 100644 --- a/code/Sokoban.icl +++ b/code/Sokoban.icl @@ -22,6 +22,8 @@ instance toString SokobanTile where toString Box = "$" toString Agent = "@" toString Target = "." + toString TargetBox = "*" + toString TargetAgent = "+" parse :: String *World -> (SokobanPuzzle, *World) parse fp w @@ -48,6 +50,8 @@ parseRow [x:xs] '$' = Box '@' = Agent '.' = Target + '+' = TargetAgent + '*' = TargetBox ' ' = Free _ = abort ("Unknown char: '" +++ toString x +++ "'") = ([current:rest], xs)