M .nix/maze-escape.nix => .nix/maze-escape.nix +5 -4
@@ 1,9 1,10 @@
-{ mkDerivation, base, hspec, lib, mtl }:
+{ mkDerivation, base, hspec, ilist, lib, mtl }:
mkDerivation {
- pname = "maze";
+ pname = "maze-escape";
version = "0.1.0.0";
src = ../.;
- libraryHaskellDepends = [ base mtl ];
- testHaskellDepends = [ base hspec ];
+ libraryHaskellDepends = [ base ilist mtl ];
+ testHaskellDepends = [ base hspec ilist mtl ];
+ homepage = "https://gitlab.com/Vonfry/maze-escape";
license = lib.licenses.gpl3Plus;
}
M lib/Game/Maze.hs => lib/Game/Maze.hs +1 -1
@@ 15,4 15,4 @@ class Maze2D map pos cell where
getCell :: map pos cell -> pos -> cell
shortestEscapePath :: map pos cell -> [pos]
- shortestEscapePath = source
+ shortestEscapePath = source -- TODO
M lib/Game/Maze/Data.hs => lib/Game/Maze/Data.hs +7 -1
@@ 4,6 4,7 @@
module Game.Maze.Data where
import Game.Maze
+import Data.List.Index (ifoldr)
data MazeCell = S -- ^ source
| D -- ^ destination
@@ 20,6 21,7 @@ instance MovableCell MazeCell where
movable _ = True
instance Maze2D MazeMapList MazeMapListPos MazeCell where
+ -- | assume the map is a matrix istead of atactic one.
adjacence map pos = [] -- TODO
getCell (MazeMapList cells) (x,y) = cells !! x !! y
@@ 31,4 33,8 @@ instance Maze2D MazeMapList MazeMapListPos MazeCell where
type MazeMap = MazeMapList MazeMapListPos MazeCell
findCellEq :: MazeMap -> MazeCell -> [MazeMapListPos]
-findCellEq (MazeMapList cells) c = [] -- TODO
+findCellEq (MazeMapList cells) c = ifoldr (flip . ifoldr . f') [] cells
+ where
+ f' i j cell poss = if cell == c then (i, j) : poss else poss
+
+
M maze-escape.cabal => maze-escape.cabal +1 -0
@@ 21,6 21,7 @@ extra-source-files: CHANGELOG.md
common deps
build-depends: base ==4.*
, mtl
+ , ilist
library
import: deps