From 6ab486c73d4d5764ac7b63c46e04c361c776385b Mon Sep 17 00:00:00 2001 From: sanine Date: Tue, 21 Nov 2023 10:35:07 -0600 Subject: add createEmptyNetwork --- src/Mind.hs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'src') 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 []) -- cgit v1.2.1