From 70252c2ef37ddf974349fa092dce92782ffd302a Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 30 Oct 2023 02:14:17 -0500 Subject: add genome creation & mutation trial --- src/util.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/util.js') diff --git a/src/util.js b/src/util.js index 9f52551..4e23d9d 100644 --- a/src/util.js +++ b/src/util.js @@ -8,3 +8,9 @@ export function create(obj, proto=Object.prototype) { return Object.create(proto, props); }; + + +export function random_choice(collection, r) { + const idx = Math.floor(collection.length * r); + return collection[idx]; +} -- cgit v1.2.1