diff options
author | sanine <sanine.not@pm.me> | 2023-11-29 17:40:38 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-11-29 17:40:38 -0600 |
commit | 4facdd8a1a5f141b158acbe1959da3d10d4c8ce9 (patch) | |
tree | a176feaa35fb8a8364742787f760de748ab95636 /test | |
parent | 98eabf2989cb3706ee05b6481b0a7221a6c23a51 (diff) |
implement parseGenome
Diffstat (limited to 'test')
-rw-r--r-- | test/GenomeTest.hs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/test/GenomeTest.hs b/test/GenomeTest.hs index aa6d310..2222347 100644 --- a/test/GenomeTest.hs +++ b/test/GenomeTest.hs @@ -2,7 +2,8 @@ module GenomeTest (suite) where import Test.Tasty import Test.Tasty.HUnit -import Mind (NeuronIndex (..)) +import Mind (Edge (..), NeuronIndex (..)) +import qualified Mind as N (Network (..)) import Genome import System.Random import Data.Ix @@ -204,4 +205,30 @@ mutationTests = testGroup "mutations" $ [ Gene { source = Internal 0, sink = Internal 1, weight = 1.0 } , Gene { source = Internal 2, sink = Output 0, weight = 1.0 } ] + , testCase "parse genome into network" $ + let + genome = Genome + { numInput = 1 + , numInternal = 3 + , numOutput = 1 + , genes = + [ Gene { source = Input 0, sink = Internal 0, weight = 1.0 } + , Gene { source = Internal 0, sink = Internal 1, weight = 2.0 } + , Gene { source = Internal 1, sink = Internal 2, weight = 3.0 } + , Gene { source = Internal 2, sink = Output 0, weight = 4.0 } + ] + } + network = parseGenome genome + expected = N.Network + { N.numInput = 1 + , N.internalNeurons = + [ [ Edge (Input 0, 1.0) ] + , [ Edge (Internal 0, 2.0) ] + , [ Edge (Internal 1, 3.0) ] + ] + , N.outputNeurons = + [ [ Edge (Internal 2, 4.0) ] + ] + } + in network @?= expected ] |