From 3a0dc840c8ea2c4b42a1051768ea43107eedbb1e Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Thu, 19 Mar 2015 20:20:58 +0000 Subject: [PATCH] implement small population migration --- sim/africa.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sim/africa.c b/sim/africa.c index 02bc447..e341e6c 100644 --- a/sim/africa.c +++ b/sim/africa.c @@ -236,7 +236,7 @@ void nextgen(struct afrhex *hexlist, int year, unsigned int climate) { #if 0 printf("hex %lld (%s) pop = [%u, %u] (%d/%d ind)\n", hex->hex, hex->climate->code, hex->freq[0], hex->freq[1], hex->pop, hex->climate->cap); #endif - /* TODO if too small, say under 25, either move everyone or die */ + /* poisson distribution on births ? */ if (pop > hex->climate->cap) { pop *= 0.6; /* should probably round down */ } else { @@ -248,9 +248,13 @@ void nextgen(struct afrhex *hexlist, int year, unsigned int climate) { hex->freq[0] = new[0] ; hex->freq[1] = new[1]; hex->pop = POP(new); + /* TODO if too small, say under 25, either move everyone or die */ hex->migrants = hex->pop - hex->climate->cap; + if (hex->pop < 25) { + hex->migrants = hex->pop; + } if (hex->migrants > 0) { - var_rhyperv(hex->migrants * 2, new, hex->outmigrate); + var_rhyperv(hex->migrants * 2, hex->freq, hex->outmigrate); /* TODO could just set it to a quarter of the cap or something */ } #if 0 @@ -324,5 +328,4 @@ void nextgen(struct afrhex *hexlist, int year, unsigned int climate) { } #endif } - } -- 2.40.0