Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fc-pregmod
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pregmodfan
fc-pregmod
Commits
a95a08e6
Commit
a95a08e6
authored
4 years ago
by
Pregmodder
Browse files
Options
Downloads
Plain Diff
Merge branch 'pregmod-master' into 'pregmod-master'
IBC improvements Closes
#2445
See merge request
!8113
parents
91316733
d7a9df80
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!8113
IBC improvements
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/js/ibcJS.js
+37
-35
37 additions, 35 deletions
src/js/ibcJS.js
with
37 additions
and
35 deletions
src/js/ibcJS.js
+
37
−
35
View file @
a95a08e6
/** @typedef IBCRelative
* An very simple object that represents a entity in a family tree.
* Represents a group of common properties shared by SlaveState, InfantState, and PlayerState,
* as well as
fetus and
genepool objects.
* as well as genepool objects.
* @type {object}
* @property {number} ID
* @property {number} mother
...
...
@@ -292,45 +292,47 @@ globalThis.ibc = (() => {
* @param {IBCRelative} s
*/
let
create_node_rec
=
s
=>
{
// Certain parents (e.g. 0, societal elite) are not considered to be related, despite
// having the same ID; convert them to null
let
m
=
or_null
(
s
.
mother
);
let
f
=
or_null
(
s
.
father
);
// Ensure that parent nodes are created
[
m
,
f
].
forEach
(
p
=>
{
if
(
p
!==
null
&&
!
(
p
in
nodes
))
{
// Not created, we have to do something
if
(
p
===
-
1
)
{
create_node_rec
(
V
.
PC
);
}
else
{
// Search for a slave state, genePool entry, or missingTable entry
let
gp
=
find_gp
(
p
);
if
(
gp
!==
null
)
{
// If we find one, we might have ancestry information: recurse
create_node_rec
(
gp
);
if
(
!
(
s
.
ID
in
nodes
))
{
nodes
[
s
.
ID
]
=
new
IBCNode
(
s
.
ID
);
// Certain parents (e.g. 0, societal elite) are not considered to be related, despite
// having the same ID; convert them to null
const
m
=
or_null
(
s
.
mother
);
const
f
=
or_null
(
s
.
father
);
// Ensure that parent nodes are created
[
m
,
f
].
forEach
(
p
=>
{
if
(
p
!==
null
&&
!
(
p
in
nodes
))
{
// Not created, we have to do something
if
(
p
===
-
1
)
{
create_node_rec
(
V
.
PC
);
}
else
{
// Otherwise, just create a plain node
nodes
[
p
]
=
new
IBCNode
(
p
);
// Search for a slave state, genePool entry, or missingTable entry
let
gp
=
find_gp
(
p
);
if
(
gp
!==
null
)
{
// If we find one, we might have ancestry information: recurse
create_node_rec
(
gp
);
}
else
{
// Otherwise, just create a plain node
nodes
[
p
]
=
new
IBCNode
(
p
);
}
}
}
}
});
});
if
(
!
(
s
.
ID
in
nodes
))
// Create this node if necessary
nodes
[
s
.
ID
]
=
new
IBCNode
(
s
.
ID
);
// We created its parents earlier, so set them to the actual nodes
nodes
[
s
.
ID
].
mother
=
(
m
===
null
)
?
m
:
nodes
[
m
];
nodes
[
s
.
ID
].
father
=
(
f
===
null
)
?
f
:
nodes
[
f
];
// Try to use a cached CoI for performance
let
sg
=
find_gp
(
s
.
ID
);
if
(
!
ignore_coeffs
&&
sg
!==
null
&&
"
inbreedingCoeff
"
in
sg
&&
sg
.
inbreedingCoeff
!==
-
1
)
{
nodes
[
s
.
ID
].
_coeff
=
sg
.
inbreedingCoeff
;
// Set parents to the actual nodes
nodes
[
s
.
ID
].
mother
=
(
m
===
null
)
?
m
:
nodes
[
m
];
nodes
[
s
.
ID
].
father
=
(
f
===
null
)
?
f
:
nodes
[
f
];
// Try to use a cached CoI for performance
let
sg
=
find_gp
(
s
.
ID
);
if
(
!
ignore_coeffs
&&
sg
!==
null
&&
"
inbreedingCoeff
"
in
sg
&&
sg
.
inbreedingCoeff
!==
-
1
)
{
nodes
[
s
.
ID
].
_coeff
=
sg
.
inbreedingCoeff
;
}
}
};
// Populate the nodes
slaves
.
forEach
(
s
=>
create_node_rec
(
s
));
slaves
.
forEach
(
s
=>
create_node_rec
(
s
));
// Populate NodeCodes
make_nc
(
nodes
);
...
...
@@ -442,13 +444,13 @@ globalThis.ibc = (() => {
all_slave_like
.
push
(
oldMaster
);
// Gather the genetics of all current fetuses
/** @type {
IBCRelative
[]} */
/** @type {
FC.FetusGenetics
[]} */
let
all_fetuses
=
V
.
slaves
.
filter
(
s
=>
s
.
preg
>
0
).
map
(
s
=>
s
.
womb
.
map
(
i
=>
i
.
genetics
)).
reduce
((
res
,
cur
)
=>
res
.
concat
(
cur
),
[]);
/** Recursively find all of the given ID's children, born and unborn
* @param {number} id
* @param {Set<number>} cur_slaves
* @param {Set<
IBCRelative
>} cur_fetuses
* @param {Set<
FC.FetusGenetics
>} cur_fetuses
* @param {Set<number>} cur_fetus_parents
*/
let
find_children_rec
=
(
id
,
cur_slaves
,
cur_fetuses
,
cur_fetus_parents
)
=>
{
...
...
@@ -476,7 +478,7 @@ globalThis.ibc = (() => {
/** @type {Set<number>} */
let
needed_slave_ids
=
new
Set
();
// Since each fetus has a unique record, a set still suffices
/** @type {Set<
IBCRelative
>} */
/** @type {Set<
FC.FetusGenetics
>} */
let
needed_fetuses
=
new
Set
();
/** @type {Set<number>} */
let
needed_parent_ids
=
new
Set
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment