From d28e8e243d3d6563c0f1036aa0b74e0d0c77c80a Mon Sep 17 00:00:00 2001 From: sanine Date: Wed, 29 Nov 2023 16:45:14 -0600 Subject: implement mutateGenomeRemoveGene --- test/GenomeTest.hs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test') diff --git a/test/GenomeTest.hs b/test/GenomeTest.hs index d775467..aa6d310 100644 --- a/test/GenomeTest.hs +++ b/test/GenomeTest.hs @@ -175,4 +175,33 @@ mutationTests = testGroup "mutations" $ validSource (source new) @?= True validSink (sink new) @?= True (w >= -4) && (w <= 4) @?= True + , testCase "remove a gene" $ + let + r = mkStdGen 1 -- randomR (0, 2) produces (1, 2, 0, ...) + 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 = 1.0 } + , Gene { source = Internal 2, sink = Output 0, weight = 1.0 } + ] + } + (genome', r') = mutateGenomeRemoveGene genome r + (genome'', r'') = mutateGenomeRemoveGene genome r' + (genome''', _) = mutateGenomeRemoveGene genome r'' + in do + genes genome' @?= + [ Gene { source = Input 0, sink = Internal 0, weight = 1.0 } + , Gene { source = Internal 2, sink = Output 0, weight = 1.0 } + ] + genes genome'' @?= + [ Gene { source = Input 0, sink = Internal 0, weight = 1.0 } + , Gene { source = Internal 0, sink = Internal 1, weight = 1.0 } + ] + genes genome''' @?= + [ Gene { source = Internal 0, sink = Internal 1, weight = 1.0 } + , Gene { source = Internal 2, sink = Output 0, weight = 1.0 } + ] ] -- cgit v1.2.1