Skip to content
This repository was archived by the owner on Apr 25, 2026. It is now read-only.

feat: Safe Breeding View#1

Merged
frankieg33 merged 4 commits intofrankieg33:mainfrom
heartskingu:feat-relation-visualizer
Mar 3, 2026
Merged

feat: Safe Breeding View#1
frankieg33 merged 4 commits intofrankieg33:mainfrom
heartskingu:feat-relation-visualizer

Conversation

@heartskingu
Copy link
Copy Markdown
Contributor

@heartskingu heartskingu commented Mar 2, 2026

Branch Notes

This PR adds a clearer way to evaluate breeding pairs by introducing a relation/risk percentage, a dedicated Safe Breeding screen, and UI zoom/accessibility improvements.

What changed

  • Fixed gender assignemnt
  • Added a new Risk% column in the main cats table.
  • Added a Safe Breeding sidebar view that ranks valid partners for a selected alive cat.
  • Added deeper lineage math helpers to estimate inbreeding risk from shared ancestry paths.
  • Added risk labels in Safe Breeding results:
    • 0-19%: Not Inbred
    • 20-49%: Slightly Inbred
    • 50-99%: Moderately Inbred
    • 100%+ (clamped to 100): Highly Inbred
  • Added UI zoom controls in Settings:
    • Zoom In (Ctrl+= / Ctrl++)
    • Zoom Out (Ctrl+-)
    • Reset Zoom (Ctrl+0)
  • Improved accessibility by enforcing minimum font sizes when scaling UI.
  • Small visual/layout tuning (including font-size consistency updates).

Math logic

The branch calculates inbreeding risk using ancestry paths and converts that to a percentage for the UI.

1) Build ancestor data

  • _ancestor_depths(cat) finds how many generations away each ancestor is.
  • _ancestor_paths(cat) builds all unique upward paths from a cat to each ancestor.
  • Paths are prevented from looping through the same cat twice.

2) Compute raw CoI (Coefficient of Inbreeding)

For each common ancestor between Cat A and Cat B:

  • take every valid path from A -> ancestor
  • combine it with every valid path from B -> ancestor
  • reject combinations that reuse the same cat on both sides (except the common ancestor)
  • add this weight to the total:

0.5 ** (sa + sb + 1)

Where:

  • sa = number of edges from A to ancestor
  • sb = number of edges from B to ancestor

So closer shared ancestors contribute more; farther ones contribute less.

3) Convert raw CoI to UI Risk%

Risk percent is normalized as:

Risk% = clamp((raw_coi / 0.25) * 100, 0, 100)

Meaning:

  • raw CoI 0.25 maps to 100% risk
  • values above that are capped at 100
  • no relation stays near 0%

4) Shared ancestor metrics used in ranking

shared_ancestor_counts(a, b) returns:

  • total_shared: all common ancestors found (within depth limit)
  • recent_shared: common ancestors where both cats are within 3 generations

In Safe Breeding sorting:

  • primary sort = lower Risk% first (safest on top)
  • secondary tie-break uses a packed value (recent_shared * 1000 + total_shared) to penalize recent shared ancestry more heavily
  • final tie-break = partner name

Safe Breeding view behavior

  • Shows only alive cats.
  • Filters out invalid pairs (same sex, self-pairing, etc.) using existing breeding rules.
  • For each candidate, displays:
    • Cat
    • Risk%
    • Shared Anc.
    • "Children will be" risk label
  • Clicking a result row switches focus to that cat.

@heartskingu heartskingu force-pushed the feat-relation-visualizer branch from bcc44c5 to 6b082bf Compare March 2, 2026 14:30
@heartskingu
Copy link
Copy Markdown
Contributor Author

@frankieg33 I've added a fix for the gender assignment logic in this PR just now

@frankieg33 frankieg33 merged commit 9ab5041 into frankieg33:main Mar 3, 2026
byronaltice referenced this pull request in byronaltice/MewgenicsBreedingManager Apr 20, 2026
byronaltice referenced this pull request in byronaltice/MewgenicsBreedingManager Apr 20, 2026
byronaltice referenced this pull request in byronaltice/MewgenicsBreedingManager Apr 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants