implement small population migration
authorNathan Wagner <nw@hydaspes.if.org>
Thu, 19 Mar 2015 20:20:58 +0000 (20:20 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Thu, 19 Mar 2015 20:28:42 +0000 (20:28 +0000)
sim/africa.c

index 02bc447abb11d2caa74f7f8428b3b7637723a81c..e341e6c4a314ed957768235c59dd45174e094ff3 100644 (file)
@@ -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
        }
-
 }