Skip to content

Commit

Permalink
New baby distribution method, after Eve window closes: Instead of rou…
Browse files Browse the repository at this point in the history
…nd-robin, we pick the family with the fewest potentially fertile females (fertile moms and girl children) left and send the next incoming baby there.
  • Loading branch information
jasonrohrer committed Sep 28, 2019
1 parent e6db3f3 commit 0de7a7f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 3 additions & 0 deletions documentation/changeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ Server Fixes
(rickety, proposed, etc.) can react to each other and auto-orient. No more
out-of-whack fences caused by them being out-of-sync when placed.

--New baby distribution method, after Eve window closes: Instead of
round-robin, we pick the family with the fewest potentially fertile females
(fertile moms and girl children) left and send the next incoming baby there.



Expand Down
45 changes: 44 additions & 1 deletion server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2667,7 +2667,7 @@ static void logFamilyCounts() {



static int getNextBabyFamilyLineageEveID() {
static int getNextBabyFamilyLineageEveIDRoundRobin() {
nextBabyFamilyIndex++;

if( nextBabyFamilyIndex >= familyCountsAfterEveWindow.size() ) {
Expand Down Expand Up @@ -6348,6 +6348,49 @@ static int countFamilies() {




static int getNextBabyFamilyLineageEveIDFewestFemales() {
SimpleVector<int> femaleCountPerFam;

int minFemales = 999999;
int minFemalesLineageEveID = -1;

for( int i=0; i<familyLineageEveIDsAfterEveWindow.size(); i++ ) {
int lineageEveID =
familyLineageEveIDsAfterEveWindow.getElementDirect( i );

int famMothers = countFertileMothers( lineageEveID );
int famGirls = countGirls( lineageEveID );

int famFemales = famMothers + famGirls;

if( famMothers > 0 ) {
// don't pick a fam that has no mothers at all
// there's no point (bb can't be born there now)

if( famFemales < minFemales ) {
minFemales = famFemales;
minFemalesLineageEveID = lineageEveID;
}
}
}

return minFemalesLineageEveID;
}



// allows us to switch back and forth between methods
static int getNextBabyFamilyLineageEveID() {
if( false ) {
// suppress unused warning
return getNextBabyFamilyLineageEveIDRoundRobin();
}
return getNextBabyFamilyLineageEveIDFewestFemales();
}



static char isEveWindow() {

if( players.size() <=
Expand Down

0 comments on commit 0de7a7f

Please sign in to comment.