@@ -19,8 +19,9 @@ struct WorkerUpdater
1919 // Sample the world
2020 for (uint32_t i (sample_count); i--;) {
2121 // Get random point in range
22- const float sample_angle = current_angle + RNGf::getRange (sample_angle_range);
23- const float distance = RNGf::getUnder (ant.marker_detection_max_dist );
22+ const float delta_angle = RNGf::getRange (sample_angle_range);
23+ const float sample_angle = current_angle + delta_angle;
24+ const float distance = RNGf::getUnder (Ant::marker_detection_max_dist);
2425 const sf::Vector2f to_marker = { cos (sample_angle), sin (sample_angle) };
2526 auto * cell = world.map .getSafe (ant.position + distance * to_marker);
2627 const HitPoint hit_result = world.map .getFirstHit (ant.position , to_marker, distance);
@@ -51,7 +52,8 @@ struct WorkerUpdater
5152 result.repellent_cell = cell;
5253 }
5354 // Check for the most intense marker
54- const float marker_intensity = to<float >(cell->getIntensity (marker_phase, ant.col_id ) * std::pow (cell->wall_dist , 2.0 ));
55+ const float wall_rep = cell->wall_dist * cell->wall_dist ;
56+ const auto marker_intensity = to<float >(cell->getIntensity (marker_phase, ant.col_id )) * wall_rep;
5557 if (marker_intensity > result.max_intensity ) {
5658 result.max_intensity = marker_intensity;
5759 result.max_direction = to_marker;
@@ -62,7 +64,8 @@ struct WorkerUpdater
6264 break ;
6365 }
6466 }
65- if (result.found_fight ) {
67+
68+ if (result.found_fight ) {
6669 ant.direction = getAngle (result.max_direction );
6770 ant.fight_mode = FightMode::ToFight;
6871 return ;
@@ -80,7 +83,8 @@ struct WorkerUpdater
8083 if (result.repellent_cell && ant.phase == Mode::ToHome) {
8184 result.repellent_cell ->getRepellent (ant.col_id ) *= 0 .95f ;
8285 }
83- // Update direction
86+
87+ // Update direction
8488 if (result.max_intensity ) {
8589 // Slowly degrade the track to accelerate its dissipation
8690 if (RNGf::proba (0 .2f ) && ant.phase == Mode::ToFood) {
0 commit comments