Closed desofity closed 3 months ago
After some debugging and testing I found that code in method
AIResourceMap::findBestPosition(const MapPoint& pt, BuildingQuality size, unsigned radius, int minimum)
inAIResourceMap.cpp
never go past the conditionif(!aiMap[idx].reachable || !aiMap[idx].owned || aiMap[idx].farmed) continue;
That is completely fine: It tries to find a position for building a fishery not a fish position. See the next line that checks the BQ of that point: https://github.com/Return-To-The-Roots/s25client/blob/6ddcdd5d82437ab54e0f17a6e0913c49621841f8/libs/s25main/ai/aijh/AIResourceMap.cpp#L91
The issue here is that the calculation of the AI ResourceMaps has a serious bug. Specifically the incremental update which is intended to save computation time is wrong and likely the initial computation is too (that part that uses the previously calculated value)
I always wanted to write a good test for that and fix it for good which should make the AI much better as it is currently running with an immense handicap.
See the original issue for more details: https://github.com/Return-To-The-Roots/s25client/issues/933 Closing this as a duplicate
Thanks for the clarification! I'll take a closer look on the original issue.
It seems that method
FindPositionForBuildingAround(BuildingType type, const MapPoint& around)
inAIPlayerJH.cpp
always returnsMapPoint::Invalid
whenBuilding::Type
isBuildingType::Fishery
, so AI never build fishery.After some debugging and testing I found that code in method
AIResourceMap::findBestPosition(const MapPoint& pt, BuildingQuality size, unsigned radius, int minimum)
inAIResourceMap.cpp
never go past the conditionif(!aiMap[idx].reachable || !aiMap[idx].owned || aiMap[idx].farmed) continue;
so it always returns initial value:MapPoint best = MapPoint::Invalid()
.I haven't found solution yet. May be it is because fish resource (atleast that's what AI debugging window shows in corresponding tab) is always on a water cells, which are of course unreachable (can't build on water). May be resource maps for fish should be like wood or stones, so the nearest buildable point to the water have biggest rating, but not the water itself.
I've watched AI on classic and custom maps with only grass and water - was no difference.