summaryrefslogtreecommitdiff
path: root/src/Mind.hs
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-21 21:23:56 -0600
committersanine <sanine.not@pm.me>2023-11-21 21:23:56 -0600
commit26be9f9dc7d57aa76e6c5eb4dd95681df3bde309 (patch)
tree43c6fea07ba6cae4b623af6fd94c89ed5fe00032 /src/Mind.hs
parenta005bcdf7b24ef60ef0a9336e27801e8d8ec70ad (diff)
implement first-pass internal neurons
Diffstat (limited to 'src/Mind.hs')
-rw-r--r--src/Mind.hs22
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 =