From 1b419a1a2a8497db3d5912d33d20b54c131b2f4c Mon Sep 17 00:00:00 2001 From: vas <whiterocket@outlook.com> Date: Wed, 5 Jun 2019 08:05:50 -0700 Subject: [PATCH] more realistic face, int genetics --- src/js/generateGenetics.js | 47 ++++++++++++-------------------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/src/js/generateGenetics.js b/src/js/generateGenetics.js index 4f31a143868..6151aeca4ff 100644 --- a/src/js/generateGenetics.js +++ b/src/js/generateGenetics.js @@ -9,6 +9,13 @@ window.generateGenetics = (function() { let activeFather; let V; + // intelligence and face parameters are the same so we can use the intelligence distribution for face values + const fuzzy = (a, b, spread=20, min=-100, max=100) => Intelligence.random({ + mean: (a+b)/2, + spread: spread, + limitIntelligence: [min, max] + }); + function generateGenetics(actor1, actor2, x) { V = State.variables; genes = { @@ -563,26 +570,14 @@ window.generateGenetics = (function() { if (actor2 === -6) { smarts = jsRandom(90, 100); } else if (father !== 0) { - if (father.intelligence < mother.intelligence) { - smarts = jsRandom(father.intelligence, mother.intelligence); - } else { - smarts = jsRandom(mother.intelligence, father.intelligence); - } - if (smarts <= 50) { - smarts += 30; - } + // player is considered "good stock" + smarts = fuzzy(father.intelligence, mother.intelligence, 20, 50, 100); } else { smarts = jsRandom(50, 100); } } else if (father !== 0) { - if (father.intelligence < mother.intelligence) { - smarts = jsRandom(father.intelligence, mother.intelligence); - } else { - smarts = jsRandom(mother.intelligence, father.intelligence); - } - if (activeMother.breedingMark === 1 && smarts <= 50) { - smarts = jsRandom(60, 100); - } + // elite slaves are also considered "good stock" + smarts = fuzzy(father.intelligence, mother.intelligence, 20, activeMother.breedingMark ? 50 : -100, 100); } else { smarts = mother.intelligence; } @@ -621,26 +616,14 @@ window.generateGenetics = (function() { if (actor2 === -6) { face = jsRandom(90, 100); } else if (father !== 0) { - if (father.face < mother.face) { - face = jsRandom(father.face, mother.face); - } else { - face = jsRandom(mother.face, father.face); - } - if (face <= 40) { - face += jsRandom(5, 20); - } + // player is considered "good stock" + face = fuzzy(father.face, mother.face, 20, 50, 100); } else { face = jsRandom(20, 100); } } else if (father !== 0) { - if (father.face < mother.face) { - face = jsRandom(father.face, mother.face); - } else { - face = jsRandom(mother.face, father.face); - } - if (activeMother.breedingMark === 1 && face < 60) { - face = jsRandom(60, 100); - } + // elite slaves are also considered "good stock" + face = fuzzy(father.face, mother.face, 20, activeMother.breedingMark ? 50 : -100, 100); } else { face = mother.face; } -- GitLab