diff --git a/src/modules/butterflies/butterflies_actions.c b/src/modules/butterflies/butterflies_actions.c index 9ab93993526199ab4f2bd8ea5eac43e1dfa5c9b9..8356e639d295fdcc93afb9685e73e4f56696c6d0 100644 --- a/src/modules/butterflies/butterflies_actions.c +++ b/src/modules/butterflies/butterflies_actions.c @@ -150,6 +150,7 @@ int64_t butterflies_prune_invalid_cells(struct cats_grid *grid) struct grid_data_butterflies *data = grid->grid_modules[module_id].module_data; cats_dt_coord rows = grid->dimension.rows; cats_dt_coord cols = grid->dimension.cols; + for (cats_dt_coord row = 0; row < rows; row++) { for (cats_dt_coord col = 0; col < cols; col++) { if (!(data->info_layer[row][col] & BF_CELL_VALID_DISPERSAL_TARGET)) { @@ -164,11 +165,11 @@ int64_t butterflies_prune_invalid_cells(struct cats_grid *grid) void initial_population_adjustment(struct cats_configuration *conf, struct cats_grid *grid) { int64_t init_populated_cells = count_populated_cells(grid); - int64_t invalid_habitat = butterflies_prune_invalid_cells(grid); + int64_t invalid_resources = butterflies_prune_invalid_cells(grid); log_message(LOG_IMPORTANT, "Loaded initial populations: %ld cells occupied before adjustment", init_populated_cells); if (grid->param.initial_population.set_to_cc == true) { -#define DEBUG_INITIAL_POPULATIONS +#define DEBUG_INITIAL_POPULATIONS 1 #ifdef DEBUG_INITIAL_POPULATIONS const int32_t max_i = 10; struct cats_vital_rate *cc_rate = &grid->param.carrying_capacity; @@ -187,6 +188,7 @@ void initial_population_adjustment(struct cats_configuration *conf, struct cats_ for (cats_dt_coord row = 0; row < rows; row++) { for (cats_dt_coord col = 0; col < cols; col++) { + if (get_adult_population(grid, row, col) == 0) continue; start += 1; cats_dt_rates multiplier = 1.0; @@ -222,7 +224,7 @@ void initial_population_adjustment(struct cats_configuration *conf, struct cats_ int64_t after_populated_cells = count_populated_cells(grid); log_message(LOG_IMPORTANT, "Pruned initial populations from %ld cells to %ld, (%ld wrong habitat)", - init_populated_cells, after_populated_cells, invalid_habitat); + init_populated_cells, after_populated_cells, invalid_resources); grid->param.initial_population.adjusted = true; }