summaryrefslogtreecommitdiff
path: root/src/simulation
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-11-12 05:22:29 -0600
committersanine <sanine.not@pm.me>2023-11-12 05:22:29 -0600
commita443171f51cf2d3b3a6c8f4e4967a3d19fd111d3 (patch)
tree4eafe5d7c9ed7093453e2dd221472fbea22c49cd /src/simulation
parent444b2b5abfbb70473b0785b38eaba1df4197ae69 (diff)
use new genome format in game.js
Diffstat (limited to 'src/simulation')
-rw-r--r--src/simulation/game.js8
-rw-r--r--src/simulation/trial.js2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/simulation/game.js b/src/simulation/game.js
index f95fbc4..17b1442 100644
--- a/src/simulation/game.js
+++ b/src/simulation/game.js
@@ -102,7 +102,7 @@ let agent_id = 0;
export function create_agent(genome, n_internal) {
return {
id: agent_id++, // !!!! side effect !!!!
- net: parse_genome(N_INPUT, N_OUTPUT, genome),
+ net: parse_genome(genome),
state: [...Array(n_internal)].map(_ => (2*Math.random()) - 1),
}
}
@@ -111,10 +111,10 @@ export function create_agent(genome, n_internal) {
export function create_team(size, genome_size, n_internal) {
const genome = apply(
- s => mut_genome_insert(s, 4, Math.random(), Math.random(), Math.random()),
+ s => mut_genome_insert(s, 4),
genome_size,
- [N_INPUT, n_internal, N_OUTPUT, []],
- ).slice(-1)[0];
+ {n_input: N_INPUT, n_internal, n_output: N_OUTPUT, genes: []},
+ );
console.log(N_INPUT, N_OUTPUT, genome);
const agents = [...Array(size)].map(_ => create_agent(genome, n_internal));
diff --git a/src/simulation/trial.js b/src/simulation/trial.js
index 3dedf01..b4462c5 100644
--- a/src/simulation/trial.js
+++ b/src/simulation/trial.js
@@ -7,6 +7,6 @@ const start_teams = [...Array(50)].map(x => create_team(32, 5, 5));
let epoch = create_epoch(start_teams);
while (epoch.epoch < 1) {
- console.log('update');
+ console.log(epoch.epoch, epoch.time, epoch.game.time);
epoch = update_epoch(epoch);
}