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/util.js | |
parent | a32853e60029fa7f08d4d713ee613ee03196fbef (diff) |
add genome creation & mutation trial
Diffstat (limited to 'src/util.js')
-rw-r--r-- | src/util.js | 6 |
1 files changed, 6 insertions, 0 deletions
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];
+}
|