@@ 1,6 1,10 @@
{-# LANGUAGE MultiParamTypeClasses #-}
-module Game.Maze where
+module Game.Maze (MovableCell(..), Maze2D(..)) where
+
+import Data.Function (on)
+import Data.Foldable (minimumBy)
+import Data.Ord (comparing)
class MovableCell cell where
movable :: cell -> Bool
@@ 15,4 19,8 @@ class Maze2D map pos cell where
getCell :: map pos cell -> pos -> cell
shortestEscapePath :: map pos cell -> [pos]
- shortestEscapePath = source -- TODO
+ shortestEscapePath = filterMinLength . fmap bfs . source
+ where
+ filterMinLength = minimumBy $ comparing length
+ -- TODO
+ bfs _ = []