tlongstretch / freeserf-with-AI-plus

THIS PROJECT WAS MOVED TO 'Forkserf', GO THERE INSTEAD
https://github.com/forkserf/forkserf
GNU General Public License v3.0
1 stars 0 forks source link

AI logic - limit the number of placed-but-not-yet-connected mines #71

Closed tlongstretch closed 3 years ago

tlongstretch commented 3 years ago

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

tlongstretch commented 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; }