Closed tlongstretch closed 3 years ago
// don't place a mine if there are already two other mines of the same type nearby, it looks messy int found = 0; for (unsigned int i = 0; i < AI::spiral_dist(15); i++) { MapPos pos = map->pos_add_extended_spirally(corner_pos, i); if (map->has_building(pos) && map->get_owner(pos) == player_index){ Building *building = game->get_building_at_pos(pos); if (building != nullptr){ if (building->get_type() == building_type){ AILogVerbose["do_place_mines"] << inventory_pos << " found another mine of type " << NameBuilding[building_type] << " near where looking to place another"; found++; } } } if (found >= 2){ break; } } if (found >= 2){ AILogDebug["do_place_mines"] << inventory_pos << " found at least two other mines of same type " << NameBuilding[building_type] << " nearby, not placing another. Skipping this corner area"; continue; }
it looks sloppy when many mines are placed, it only makes sense to place a couple extras per type. Maybe add a check to see if more than 1 is nearby, don't place