Strange AI Building Placement Problem

Strange AI Building Placement Problem

Here is where ideas can be collected for the skirmish AI in development

Moderators: hoijui, Moderators

Post Reply
SiriusDragon
Posts: 14
Joined: 21 Mar 2010, 07:13

Strange AI Building Placement Problem

Post by SiriusDragon »

Hi world,

I could be doing something dumb with this, I don't know... basically what happens is that my AI builds the following:

1. Mex
2. Solar
3. Solar
4. Aircraft Plant

BUT it gets stuck with number 4. What seems to happen is that after making number 3, it picks a build spot right up against that building for the Aircraft plant. Obviously that won't work or fit so it fails.

I'm using the AI API function (FindClosestBuildSite) to find the build site, so I'm not sure why it's picking such a bad build site for that specific building.

The parameters I'm passing to that function are as follows:

unit def = unit def of the aircraft plant
pos = current position of the commander
search radius = 8192
minimum distance = 32
facing = no facing

The mod I'm using is BOTA 1.6, and the API is the new C++ API.

Any ideas on what I could be doing wrong? I simply want my AI to make those few buildings, so I can then get the factory to make some air scouts.

I may try shuffling the build order and put the Aircraft Factory first, but that seems like more of a hack than a proper fix.

Thanks for any help!
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: Strange AI Building Placement Problem

Post by hoijui »

are you calling FindClosestBuildSite() after the 2nd solar was built?
maybe wait a frame or two, though the idle event should work, i guess.
SiriusDragon
Posts: 14
Joined: 21 Mar 2010, 07:13

Re: Strange AI Building Placement Problem

Post by SiriusDragon »

Yes, that's correct. I call FindClosestBuildSite for each building before it's built. I will see if I can work out a way to delay the build process by a bit and see if that helps.

I just find it odd that it only seems to affect the aircraft factory - if I specify a min distance and use mexes and solars, it'll build them apart from each other. But the factory seems to 'ignore' this restriction and is built right next to the building proceeding it.

Currently my build queue system is 'dumb' in the sense that it can't handle blockages like this. In the future I hope it can so this doesn't keep happening as the base gets more elaborate.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Strange AI Building Placement Problem

Post by AF »

There's a subtle issue in how the API behaves which people don't quite understand because it isn't obvious

If Im building a solar, and I have a minimum distance of 1, what is the minimum distance in unit/build squares of 16 (footprint units)?

The expected value is 1 unit, that actual value is 1 solar footprint. As the size of the solars footprint rises so does the size of the minimum distance despite the value remaining the same.

Now I may be wrong in the exact ratios,or the connection, but the minimum distance is not a constant value and is tied to the footprint and size of said unit, this is why a position which works for a solar and an aircraft plant, may be found when looking for place to build the solar but not the aircraft plant.

Doing it this way has it's uses and if you look at the Shard source code, I have a small piece of math to adjust the values and normalise them into the same units as search radius.
Post Reply

Return to “AI”