From a2433638df217817d02d86eb75cdb912b18cd50a Mon Sep 17 00:00:00 2001 From: jbetzend Date: Fri, 18 Apr 2014 14:28:32 +0200 Subject: [PATCH 1/3] docs --- src/Map/StaticMaps.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Map/StaticMaps.hs b/src/Map/StaticMaps.hs index 895fdc5..b88340c 100644 --- a/src/Map/StaticMaps.hs +++ b/src/Map/StaticMaps.hs @@ -4,8 +4,17 @@ where import Map.Types import Data.Array -gauss2Dgeneral :: Floating q => q -> q -> q -> q -> q -> q -> q -> q -gauss2Dgeneral amp x0 y0 sX sY x y = amp * exp (-(((x-x0)^2/(2 * sX^2))+((y-y0)^2/(2 * sY^2)))) +-- general 2D-Gaussian +gauss2Dgeneral :: Floating q => + q -- ^ Amplitude + -> q -- ^ Origin on X-Achsis + -> q -- ^ Origin on Y-Achsis + -> q -- ^ Sigma on X + -> q -- ^ Sigma on Y + -> q -- ^ Coordinate in question on X + -> q -- ^ Coordinate in question on Y + -> q -- ^ elevation on coordinate in question +gauss2Dgeneral amp x0 y0 sX sY x y = amp * exp(-(((x-x0)^2/(2 * sX^2))+((y-y0)^2/(2 * sY^2)))) gauss2D :: Floating q => q -> q -> q gauss2D x y = gauss2Dgeneral 15 100.0 100.0 15.0 15.0 x y From ee8c91237cfb12501f79c6fe4cbc9be11c125a40 Mon Sep 17 00:00:00 2001 From: jbetzend Date: Fri, 18 Apr 2014 16:07:26 +0200 Subject: [PATCH 2/3] Took out annotation (Haddock complained) and improved path type --- src/Map/Graphics.hs | 5 +---- src/Map/Types.hs | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Map/Graphics.hs b/src/Map/Graphics.hs index f8562a5..67a0b37 100644 --- a/src/Map/Graphics.hs +++ b/src/Map/Graphics.hs @@ -33,10 +33,7 @@ import Linear import Map.Types import Map.StaticMaps -type MapEntry = ( - Float, -- ^ Height - TileType - ) +type MapEntry = (Float, TileType) type GraphicsMap = Array (Int, Int) MapEntry diff --git a/src/Map/Types.hs b/src/Map/Types.hs index f55afc1..2599f5c 100644 --- a/src/Map/Types.hs +++ b/src/Map/Types.hs @@ -9,7 +9,7 @@ type PlayMap = Array (XCoord, ZCoord) Node type XCoord = Int type ZCoord = Int -type YCoord = Float +type YCoord = Float data MapType = GrassIslandMap | DesertMap @@ -22,10 +22,10 @@ instance Show PlayerInfo where show (NoPlayer) = "not occupied" show (Occupied i) = "occupied by player " ++ (show i) --- | Path info, is this node part of a path? +-- | Path info, is this node part of a path and if so, where does it lead? data PathInfo = NoPath - | Path | Border + | Paths [(XCoord, YCoord)] deriving (Show, Eq) -- | What resources can be harvested here? From ebae8dd593dbdf7cb1884a8b38e3fdf5f73ace70 Mon Sep 17 00:00:00 2001 From: jbetzend Date: Fri, 18 Apr 2014 16:07:51 +0200 Subject: [PATCH 3/3] 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