Strange AI behavior with gold harvesting very early game

Something worth looking into, not sure if a bug or AI was taking an alternative approach (I don’t know what that is).

I base this from the perspective of, “if I were the AI I would never do that because of time and resource loss”.

Unexpected behavior:
Very early game 2-3 minutes in the AI builds a mine next to a large gold node, but then later switches to a smaller node.

Expected behavior:
AI builds a mine and sticks with that mine until it is depleted.

This was encountered with a generated mod map, and the AI player abilities have been untouched. Assuming that generated maps share the same AI player logic, this can happen on any native generated map.

That happens with lumber camps and mills too, on any map. The AI essentially is filtering positions utility and it happens that both are considered good mining positions. The current workaround Relic does is just delaying each camp building by 30 seconds “-- When produced, pause production for some time, to let various parts of the AI react to the new drop off” and it doesn’t work all the time.

See the code :

function ScoringFunctions_DropOffs(aiPlayer)
	return 
	{
		AIProductionScoring_PlannedPlacementScore(aiPlayer, 0.48),
		AIProductionScoring_StrategicIntention(aiPlayer, { ["economy"] = 1.0}),
		AIProductionScoring_DropOffScore(aiPlayer),
		-- When produced, pause production for some time, to let various parts of the AI react to the new drop off
		AIProductionScoring_NotProducedRecently(aiPlayer, 30.0)
	}
end

Lumber camps aren’t build more often due to requiring PlannedPlacementScore of 0.48.

There are a lot worse things about the AI gathering system.

1 Like

Wow, super interesting. It sounds like you’ve been digging into a lot of the AI behavior.

I know very little when it comes to AI behavior and logic, but from a programming standpoint it seems like a weighted resource system is needed, or perhaps it’s already in place but other conditions are interfering?

This is what I would be asking if I were AI, but I wouldn’t doubt the game already tests these conditions but can be completely wrong. It’s always easier speak it than to program it.

“How many mining positions do I have and do I need more?”
“Do I have enough gold or am I running out of gold?”
“Do I have any villagers on gold?”
“I’m running out of gold, what is the closest spot to build next mine?”

Unless Relic’s idea for the AI is to build and capitalize. Boom by whatever means necessary. It built a mine first and moved as intentional behavior because it would shift vills to previous mine with no FoW. The previously built mine is something it can see, and is placing it in it’s back pocket for later.

I’d be curious if there was something more involved here.

From many hours of testing resource dropoffs are simply filtered by positional improvements (PlannedPlacementScore) where it scores higher if the resources are further from the closest dropoffs. If I simply delete the dropoffs scoring and use the legacy one the AI will continuously build dropoffs for the respective res everywhere.

The Intention is supposedly the main strategic brain for the AI and it fluctuates scoring from 0.0 to 1.0 (float)

There’s a lot of AIProductionScoring functions you can browse thru the modding tools (Scriptiing → Documentation) but as of now we have no way to modify the AI scoring functions because they’re locked, it’s in the ai\.scar and ai\personality\.scar. I’ve been saying to Relic to release these files to be modded but as of now it’s not yet moddable.

I only mod the AI, I’m not interested in other forms of modding. It has been the case for me since the original AoE2.

1 Like

Thanks, all! The team is always looking to improve AI behavior. I’ll pass this specific behavior along. Much appreciated!