summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Mind.hs27
-rw-r--r--test/MindTest.hs10
2 files changed, 32 insertions, 5 deletions
diff --git a/src/Mind.hs b/src/Mind.hs
index 02b98b1..45b90da 100644
--- a/src/Mind.hs
+++ b/src/Mind.hs
@@ -1,11 +1,30 @@
module Mind
( NeuronIndex (..)
, getNeuronIndex
+
+ , Edge (..)
+
+ , Network (..)
+ , createEmptyNetwork
) where
--- types
-data NeuronIndex = Input Int | Internal Int | Output Int
+-- index different neuron types
+data NeuronIndex = Input Int | Internal Int | Output Int deriving (Show, Eq)
+
getNeuronIndex :: NeuronIndex -> Int
-getNeuronIndex i = undefined
+getNeuronIndex (Input i) = i
+getNeuronIndex (Internal i) = i
+getNeuronIndex (Output i) = i
+
+-- define incident edges
+newtype Edge = Edge (NeuronIndex, Float) deriving (Show, Eq)
+
+-- define networks
+data Network = Network
+ { numInput :: Int
+ , internalNeurons :: [[Edge]]
+ , outputNeurons :: [[Edge]]
+ } deriving (Show, Eq)
-newtype Edge = Edge (NeuronIndex, Float)
+createEmptyNetwork :: Int -> Int -> Int -> Network
+createEmptyNetwork i h o = Network i (replicate h []) (replicate o [])
diff --git a/test/MindTest.hs b/test/MindTest.hs
index 227aa0c..5eb1734 100644
--- a/test/MindTest.hs
+++ b/test/MindTest.hs
@@ -2,15 +2,23 @@ module MindTest (suite) where
import Test.Tasty
import Test.Tasty.HUnit
-
import Mind
suite :: TestTree
suite = testGroup "mind tests" $
[ neuronIndexTests
+ , networkTests
]
neuronIndexTests :: TestTree
neuronIndexTests = testGroup "neuron index tests" $
[ testCase "get input index" $ getNeuronIndex (Input 4) @?= 4
+ , testCase "get internal index" $ getNeuronIndex (Internal 12) @?= 12
+ , testCase "get output index" $ getNeuronIndex (Output 0) @?= 0
+ ]
+
+networkTests :: TestTree
+networkTests = testGroup "network tests" $
+ [ testCase "create empty network" $
+ (createEmptyNetwork 3 2 1) @?= Network 3 [[], []] [[]]
]