void update_shanty (void) { int i, pp; pp = people_pool - (COMMUNE_POP * numof_communes); i = (pp - SHANTY_MIN_PP) / SHANTY_POP; if (i > numof_shanties) add_a_shanty (); /* vv-- schmitt trigger */ else if (numof_shanties > 0 && i < (numof_shanties - 1)) remove_a_shanty (); else if (numof_shanties > 0 && rand () % 100 == 10) remove_a_shanty (); /* randomly close some down. */ }
void update_shanty(void) { int numof_communes = Counted<Commune>::getInstanceCount(); int numof_shanties = Counted<Shanty>::getInstanceCount(); const int len = world.len(); //Foersts make new people? Why not //people_pool += .3 * numof_communes; int pp = people_pool; people_pool -= 5 * numof_shanties; if (people_pool < 0) { people_pool = 0; } ddeaths += (pp - people_pool); pp = people_pool - (COMMUNE_POP * numof_communes); int i = (pp - SHANTY_MIN_PP) / SHANTY_POP; if (i < 0) { i = 0;} if (i > numof_shanties) { for (int n = 0; n < 1 + (i - numof_shanties)/10; n++) { add_a_shanty();} } else if (numof_shanties > 0 && (i < (numof_shanties - 1) )) { for (int n = 0; n < (1+(numof_shanties - i)/10); n++) { int x, y, r; x = rand() % len; y = rand() % len; r = find_group(x, y, GROUP_SHANTY); if (r == -1) { fprintf(stderr, "Can't find a shanty to remove!\n"); return; } y = r / len; x = r % len; ConstructionManager::executeRequest(new BurnDownRequest(world(x,y)->reportingConstruction)); } } }