From ebae8dd593dbdf7cb1884a8b38e3fdf5f73ace70 Mon Sep 17 00:00:00 2001 From: jbetzend Date: Fri, 18 Apr 2014 16:07:51 +0200 Subject: [PATCH] Added Map.Maps with Neighbourfunction --- src/Map/Maps.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/Map/Maps.hs diff --git a/src/Map/Maps.hs b/src/Map/Maps.hs new file mode 100644 index 0000000..3703246 --- /dev/null +++ b/src/Map/Maps.hs @@ -0,0 +1,14 @@ +module Map.Maps +where + +import Map.Types + +-- potentially to be expanded to Nodes +giveNeighbours :: (Int, Int) -> [(Int,Int)] +giveNeighbours (x,y) = filter (not . negative) all + where + all = if even y then [(x+1,y), (x-1,y), (x,y+1), (x,y-1), (x+1,y+1), (x+1,y-1)] + else [(x+1,y), (x-1,y), (x,y+1), (x,y-1), (x-1,y+1), (x-1,y-1)] + + negative :: (Int, Int) -> Bool + negative (x,y) = x < 0 || y < 0