diff options
Diffstat (limited to 'src/Mind.hs')
-rw-r--r-- | src/Mind.hs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Mind.hs b/src/Mind.hs index cb78a1e..70b7494 100644 --- a/src/Mind.hs +++ b/src/Mind.hs @@ -121,21 +121,23 @@ getValue net inputState state' (Internal x) = in if isJust cached then (fromJust cached, state') else let - (value, ns) = foldEdges net inputState state' (internalNeurons net !! x) + (value, ns) = foldEdges net inputState state' (Internal x) (internalNeurons net !! x) nss = updateValue ns x value in (value, nss) getValue net inputState state' (Output x) = - foldEdges net inputState state' (outputNeurons net !! x) + foldEdges net inputState state' (Output x) (outputNeurons net !! x) -foldEdges:: Network -> InputState -> NewState -> [Edge] -> (Float, NewState) -foldEdges net (input, state) state' edges = +foldEdges:: Network -> InputState -> NewState -> NeuronIndex -> [Edge] -> (Float, NewState) +foldEdges net (input, state) state' sink edges = let (total, ns) = foldl (\(total, ns) (Edge (source, w)) -> let - (value, ns') = getValue net (input, state) ns source + (value, ns') = if (sink == source) + then (state !! (getNeuronIndex source), ns) + else getValue net (input, state) ns source total' = (w * value) + total in (total', ns') ) |