deathmetal Posted December 14, 2022 Share Posted December 14, 2022 Hey all, I'm currently working on programming a game in PHP (in Laravel 9) that features an extensive and realistic breeding system. One of the most important aspects about such a system, in my eyes, is the implementation and handling of inbreeding in a manner that reflects reality. I consider myself to be well versed in genetics, and I don't need help in terms of actually calculating the COI as I will probably implement a simpler but mostly identical system for the purpose of its existence in my game (AVK, Ancestor Loss Coefficient), however, I'm curious as to how others would tackle an issue I'm currently facing. The calculation requires an array of all the ancestors of the animal, but I'm not sure what the best way to implement this would be. In my ideal scenario, the number would be calculated across an animal's entire pedigree, even if it's hundreds of generations long, but that doesn't sound like it'd be manageable, so I may have to settle on capping it for a specific number of generations to factor in for the calculation. Assuming that the table contains 3 relevant fields, animal_id, sire_id, and dam_id, what is the best way to retrieve the entire list of ancestors for a particular animal in Laravel-y way? I can't come up with any solutions that wouldn't involve doing potentially hundreds of queries in rapid succession-would that be a performance killer? Maybe there's a way I can alter the animal table in a way where it includes more information on the ancestors so it doesn't need to be as many queries, but the thought of doing so many queries at once still sounds awful, and I'd like to keep the animals table as small as possible since it's already much larger with the genetic encoding system. Any help or advice is appreciated, since my knowledge on designing such complicated tasks for scale is super limited. Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.