summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-29 16:45:14 -0600
committersanine <sanine.not@pm.me>2023-11-29 16:45:14 -0600
commitd28e8e243d3d6563c0f1036aa0b74e0d0c77c80a (patch)
treec09770815f64468c65bfb99823bb223879a3b5bb /test
parent4c63f3d4dba0c7164cce9559f09dc82612cdee36 (diff)
implement mutateGenomeRemoveGene
Diffstat (limited to 'test')
-rw-r--r--test/GenomeTest.hs29
1 files changed, 29 insertions, 0 deletions
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 }
+ ]
]