summaryrefslogtreecommitdiff
path: root/src/genome/genome.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/genome/genome.js')
-rw-r--r--src/genome/genome.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/genome/genome.js b/src/genome/genome.js
index 7688b32..d35b68c 100644
--- a/src/genome/genome.js
+++ b/src/genome/genome.js
@@ -104,3 +104,19 @@ export function mut_genome_expand(
n_input, n_internal+1, n_output, new_genome,
];
}
+
+
+export function mut_genome_insert(
+ [n_input, n_internal, n_output, genome],
+ weight_max,
+ r1, r2, r3
+) {
+ const source = Math.floor((n_input + n_internal) * r1);
+ const sink = Math.floor((n_internal + n_output) * r2) + n_input;
+ const weight = weight_max * ((2*r3)-1);
+
+ return [
+ n_input, n_internal, n_output,
+ [...genome, [source, sink, weight]],
+ ];
+}