diff options
author | sanine <sanine.not@pm.me> | 2023-10-30 02:14:17 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-10-30 02:14:17 -0500 |
commit | 70252c2ef37ddf974349fa092dce92782ffd302a (patch) | |
tree | 746b648674bb2b7befbd17c38d9e2d01ff4adfb3 /src/genome/trial.js | |
parent | a32853e60029fa7f08d4d713ee613ee03196fbef (diff) |
add genome creation & mutation trial
Diffstat (limited to 'src/genome/trial.js')
-rw-r--r-- | src/genome/trial.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/genome/trial.js b/src/genome/trial.js new file mode 100644 index 0000000..2ce23bf --- /dev/null +++ b/src/genome/trial.js @@ -0,0 +1,37 @@ +import { + get_size, + mut_genome_insert, mutate_genome, +} from './genome.js'; + +const recurse = (f, x0, n) => { + if (n == 0) { + return x0; + } else { + return f(recurse(f, x0, n-1)); + } +}; + + +const n_input = 5; +const n_output = 5; + + +const [_1, _2, _3, genome] = recurse( + s => mut_genome_insert( + s, 4, + Math.random(), Math.random(), Math.random() + ), + [n_input, 10, n_output, []], + 20); + + +const n_internal = get_size(n_input, n_output, genome) - n_input - n_output; +console.log([n_input, n_internal, n_output, genome]); + +const mutation = recurse( + s => mutate_genome(s, 4), + [n_input, n_internal, n_output, genome], + 40 +); + +console.log(mutation); |