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 - seeing new issue where Mill and Baker sometimes not built around farm #73

Closed tlongstretch closed 3 years ago

tlongstretch commented 3 years ago

I'm thinking it doesn't have enough positions to consider because it only looks in a spiral 12-tiles wide around each Farm attached to the current inventory pos, but what if there's no space? I think it just gives up

if this is the actual cause, maybe just make the circle bigger? Or allow it to be built anywhere??

tlongstretch commented 3 years ago

ah I had a bug where the "avoid building large buildings near enemy borders" was considering UNOWNED borders not just enemy

fixed // don't build large civilian buildings, including stocks, near enemy borders if (building_type >= Building::TypeStock && building_type != Building::TypeHut && building_type != Building::TypeTower && building_type != Building::TypeForester){ AILogDebug["util_build_near_pos"] << name << " this is a Large Civilian building, checking to see if enemy borders are near"; for (unsigned int i = 0; i < AI::spiral_dist(8); i++) { MapPos pos = map->pos_add_extended_spirally(center_pos, i); // if not mine and not unowned (i.e. owned by somebody else) if (map->get_owner(pos) != player_index && map->get_owner(pos) != -1) { AILogDebug["util_build_near_pos"] << name << " found enemy borders near this potential build_near_pos center and this is a Large Civilian building! Not building in this area, returning"; return bad_map_pos; } }