diff options
Diffstat (limited to 'src/Mind.hs')
-rw-r--r-- | src/Mind.hs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/Mind.hs b/src/Mind.hs index 1ee70bc..cb78a1e 100644 --- a/src/Mind.hs +++ b/src/Mind.hs @@ -77,20 +77,36 @@ insertEdge ns i e -- network computation compute :: Network -> [Float] -> [Float] -> Maybe ([Float], [Float]) -compute net input state = Just $ (output net input state, []) +compute net input state = + let + s = newState net input state + state' = map (Just) s + in Just $ (output net input state state', s) type InputState = ([Float], [Float]) type NewState = [Maybe Float] -output net input state = +output net input state state'= let - state' = replicate (length $ internalNeurons net) Nothing numOutput = length $ outputNeurons net in map ((fst . getValue net (input, state) state') . Output) [0..numOutput-1] +newState :: Network -> [Float] -> [Float] -> [Float] +newState net input state = + let numInternal = length $ internalNeurons net + in fst $ + foldr + (\x (r, ns) -> + let (value, ns') = getValue net (input, state) ns (Internal x) + in (value:r, ns') + ) + ([], replicate numInternal Nothing) + [0..numInternal-1] + + updateValue :: NewState -> Int -> Float -> NewState updateValue state' index value = |