Skip to content
Snippets Groups Projects
Commit 4c0abf46 authored by Empress Sela's avatar Empress Sela
Browse files

Fixes

- Fix reference to genePool
- Prioritize genePool records over slave records when reusing CoI
- Don't automatically store values to genepool; do this elsewhere
parent 259297ca
No related branches found
No related tags found
No related merge requests found
window.ibc = (() => {
globalThis.ibc = (() => {
// These IDs are considered to be unknown parents
let or_null = (s) => specificCharacterID(s) ? s : null;
let find_gp = (id) => (slaveStateById(id) || genePool.find((s) => s.ID == id) || null);
let find_gp = (id) => (SugarCube.State.variables.genePool.find((s) => s.ID == id) || slaveStateById(id) || null);
// Create a node for the given ID
let create_node = (id) => ({
......@@ -253,7 +253,8 @@ window.ibc = (() => {
nodes[s.ID].father = (f === null) ? f : nodes[f];
let sg = find_gp(s.ID);
if ("inbreedingCoeff" in sg && sg.inbreedingCoeff !== -1) {
if (sg !== null && "inbreedingCoeff" in sg && sg.inbreedingCoeff !== -1) {
console.log("Found "+s.ID);
nodes[s.ID]._coeff = sg.inbreedingCoeff;
}
};
......@@ -278,16 +279,6 @@ window.ibc = (() => {
ret[s.ID] = coeff(nodes[s.ID]);
});
Object.keys(nodes).forEach(s => {
let n = nodes[s];
if (n.id in SugarCube.State.variables.slaveIndices) {
let slave = find_gp(n.id);
if (!("inbreedingCoeff" in slave) || slave.inbreedingCoeff === -1) {
slave.inbreedingCoeff = n._coeff;
}
}
});
return ret;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment