Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: Improvement to the calculation for determining the base area that AI Bots claim. (As done by Cobra) #4178

Open
Chewbakka-Wakka opened this issue Jan 16, 2025 · 2 comments
Labels

Comments

@Chewbakka-Wakka
Copy link

For Cobra on function cobraBaseArea() within mapDynamics.js

const EXTRA_TILES = 20
area.x1 = area.x1 - EXTRA_TILES;
etc..
Where the baseStructures subtract from our available build area.

Now I might add that two terrain types should also be factored into this equation to also subtract from our available build area, namely:

if (tileType === TER_WATER || tileType === TER_CLIFFFACE) - As... those terrain types cannot be built upon.

This could explain why Cobra makes odd building choices exposing baseStructures out in the open near the base, where TER_CLIFFFACE is apparent and blocking much of nearby area. ( A simple test on Sk-Rush shows this. )

Also occurs to me that destructible features should also subtract from our available build area, until they are destroyed.
Along with oil resource(s).

Thoughts @KJeff01 ?

Digression:
This value for const EXTRA_TILES = 20, may be better off being set based on some other set of conditions on map analysis.

@KJeff01
Copy link
Member

KJeff01 commented Jan 17, 2025

This logic doesn't affect build position decisions. It's used for tactics code to scan if enemy units are encroaching upon Cobra's territory, and if so, to allow attacking behavior. Very useful for NTW maps I will add.

The reason for why strange build locations happen is a little more complex. From what I remember bots build in a circle, usually around the startPosition coordinates with pickStructLocation() returning a valid position. Poor building placement on Rush in particular can be dependent on the specific player slot, and also influenced by the build order that occurred. Cobra may be more likely to hit bad spots due to faking its startPosition with a small random offset each time it builds (to improve something I've forgotten about by now--maybe to prevent trucks building on top of themselves and getting stuck forever, idk). But it's not a unique problem with Cobra as I've seen other bots build behind their base often.

Ultimately if pickStructLocation() accounted for path distances instead of straight lines it would massively improve bot build locations on all maps, probably. Without the need for clever and complex logic at the script level.

I've ran out of ideas on improving Cobra, so feel free to add ideas to my issues section in my Cobra repo if you want.

@Chewbakka-Wakka
Copy link
Author

My mistake, of course... pickStructLocation().

"used for tactics code ... Very useful for NTW maps" - Noted, I would like to observe this in action so will take a look later.

"(to improve something I've forgotten about by now--maybe to prevent trucks building on top of themselves and getting stuck forever, idk)" - yes I have seen something about this and it is commented within some code on that basis.
This specific issue has, very recently been fixed I believe. This can be tested to verify.

Now that you mention it, when it comes to Sk-Rush every or most AIs build south of whatever base they occupy.

Another off topic quirk I discovered, is that as an enemy player if you place a unit on the location underneath where the AI wishes to build... it never builds and hangs on looping trying to place the structure on that otherwise valid location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants