~vonfry/maze-escape

70ae5e5d0c6a5ce5aeb0ff0c79626545ebbdc4c0 — Vonfry 2 years ago 2fe10f6
maze: framework for shortest escape path
1 files changed, 10 insertions(+), 2 deletions(-)

M lib/Game/Maze.hs
M lib/Game/Maze.hs => lib/Game/Maze.hs +10 -2
@@ 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 _ = []