diff --git a/src/modules/butterflies/butterflies_actions.c b/src/modules/butterflies/butterflies_actions.c index 8aa296c4ac92134e0f3362457b2c15c4b2445ffd..01b536944a46e0d6fd7b324c510c55e6ca21fa4e 100644 --- a/src/modules/butterflies/butterflies_actions.c +++ b/src/modules/butterflies/butterflies_actions.c @@ -183,14 +183,6 @@ void butterflies_area_dispersal(struct cats_grid *grid, struct cats_thread_info butterflies_cell_dispersal(grid, ts, row, col, false, false); } } - - /* - if (ts->rw_debug_cells_with_adults) { - log_message(LOG_INFO, "thread %d: %ld cells with adults, %ld random walks, %ld deposits", - ts->id, ts->rw_debug_cells_with_adults, ts->rw_debug_random_walks, ts->rw_debug_deposits); - } - */ - } @@ -250,9 +242,10 @@ enum action_status bf_action_dispersal(struct cats_grid *grid, struct cats_confi threaded_action(&butterflies_area_dispersal, grid, conf, TS_DISPERSAL); struct conf_data_butterflies *module_conf = CATS_MODULE_DATA; - for (enum butterfly_stats which = BF_RANDOM_WALK_DEPOSIT_COUNT; which < BF_STAT_MAX; which++) { + for (enum butterfly_stats which = BF_RANDOM_WALK_DEPOSIT_COUNT; which < BF_OUTPUT_STAT_MAX; which++) { int64_t stat_id = module_conf->stat_ids[which]; - log_message(LOG_INFO, "STAT %s: %ld", bf_get_stats_field_name(which), grid->stats.stats[stat_id]); + log_message(LOG_INFO, "STAT %s (%ld): %ld", bf_get_stats_field_name(which), stat_id, + grid->stats.custom_stats[stat_id]); } return ACTION_RUN; @@ -300,8 +293,7 @@ enum action_status bf_action_generation_update(struct cats_grid *grid, struct ca int64_t cells_with_eggs_removed = grid->stats.custom_stats[egg_cells_removed_id]; log_message(LOG_INFO, "%ld cells with eggs left, %ld cells with eggs removed", cells_with_eggs, cells_with_eggs_removed); - grid->stats.custom_stats[egg_cells_id] = 0; - grid->stats.custom_stats[egg_cells_removed_id] = 0; + return ACTION_RUN; } @@ -312,7 +304,6 @@ enum action_status bf_action_overlay_update(struct cats_grid *grid, struct cats_ } - enum action_status bf_action_generation_finish(struct cats_grid *grid, struct cats_configuration *conf) { const int module_id = CATS_MODULE_ID; @@ -322,7 +313,7 @@ enum action_status bf_action_generation_finish(struct cats_grid *grid, struct ca data->generation_current--; assert(data->generation_current >= 0); - // struct conf_data_butterflies *data = CATS_MODULE_DATA; + return ACTION_RUN; } diff --git a/src/modules/butterflies/butterflies_dispersal.c b/src/modules/butterflies/butterflies_dispersal.c index 7448a98e88ae635efa25c5f45229521b8a3bc69b..cc13ac925c747e41e4845a5612c002c192f1ca2e 100644 --- a/src/modules/butterflies/butterflies_dispersal.c +++ b/src/modules/butterflies/butterflies_dispersal.c @@ -42,6 +42,7 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g const struct conf_data_butterflies *module_conf = CATS_MODULE_DATA; const bool debug_rw = module_conf->debug_rw; const int64_t stat_id_deposits = module_conf->stat_ids[BF_RANDOM_WALK_DEPOSIT_COUNT]; + const int64_t stat_id_rw_steps = module_conf->stat_ids[BF_RANDOM_WALK_STEP_COUNT]; int32_t eggs_left = eggs; const cats_dt_coord max_steps = module_conf->animal_dispersal_max_radius; @@ -72,6 +73,8 @@ static void inline single_random_walk(struct cats_thread_info *ts, struct cats_g return; // we escaped the simulation extent and got lost } + increase_custom_stat(ts->stats, stat_id_rw_steps, 1); + // is the cell a valid dispersal target location? if (!(data->info_layer[row][col] & BF_CELL_VALID_DISPERSAL_TARGET)) { @@ -214,7 +217,6 @@ butterflies_cell_dispersal(struct cats_grid *grid, struct cats_thread_info *ts, } - single_random_walk(ts, grid, row, col, eggs_to_disperse_per_female, egg_fraction_step, rw_number); increase_custom_stat(ts->stats, stat_id_rw, 1); diff --git a/src/modules/butterflies/butterflies_stats.c b/src/modules/butterflies/butterflies_stats.c index 3a866172ba742ed7c2a694e9a6fce3fee392bccb..355658a9c9e2ae3eb74ad8fa7fa9110b1eeda4e7 100644 --- a/src/modules/butterflies/butterflies_stats.c +++ b/src/modules/butterflies/butterflies_stats.c @@ -26,12 +26,10 @@ const char *bf_get_stats_field_name(enum butterfly_stats which) return "unpopulated_unfit"; case BF_STAT_EXCLUDED: return "excluded"; - case BF_RANDOM_WALK_DEPOSIT_COUNT: return "random_walk_deposit_count"; case BF_RANDOM_WALK_COUNT: return "random_walk_count"; - case BF_RANDOM_WALK_STEP_COUNT: return "random_walk_step_count"; case BF_OUTPUT_STAT_MAX: diff --git a/src/modules/butterflies/butterflies_stats.h b/src/modules/butterflies/butterflies_stats.h index 7537718b98f3fa814ef15682b0911277624ef51e..1e58d674b9df4710e4886c2c40dd950aec7c349f 100644 --- a/src/modules/butterflies/butterflies_stats.h +++ b/src/modules/butterflies/butterflies_stats.h @@ -16,9 +16,9 @@ enum butterfly_stats { BF_RANDOM_WALK_DEPOSIT_COUNT, BF_RANDOM_WALK_COUNT, BF_RANDOM_WALK_STEP_COUNT, + BF_OUTPUT_STAT_MAX, BF_CELLS_WITH_EGGS, BF_CELLS_WITH_EGGS_REMOVED, - BF_OUTPUT_STAT_MAX, BF_STAT_MAX }; @@ -31,7 +31,6 @@ static inline void increase_custom_stat(struct statistics *stats, int64_t stat_i assert(stats != NULL); assert(stat_id >= 0 && stat_id < stats->custom_stat_count); stats->custom_stats[stat_id] += by; - }