From 17fc9fe64f4de1bc58596034c54ddb487f992c9f Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 30 Oct 2023 01:00:53 -0500 Subject: add mut_genome_delete --- src/genome/genome.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/genome/genome.js') diff --git a/src/genome/genome.js b/src/genome/genome.js index d35b68c..16b5e4d 100644 --- a/src/genome/genome.js +++ b/src/genome/genome.js @@ -120,3 +120,12 @@ export function mut_genome_insert( [...genome, [source, sink, weight]], ]; } + + +export function mut_genome_delete( + [n_input, n_internal, n_output, genome], r +) { + const del_idx = Math.floor(r * genome.length); + const new_genome = genome.filter((_, idx) => idx != del_idx); + return [n_input, n_internal, n_output, new_genome]; +} -- cgit v1.2.1