Giter Club home page Giter Club logo

Comments (7)

dnqbob avatar dnqbob commented on July 18, 2024 1

@Inq8
@darkademic

The scanning of HarvesterBotModuleCA is the causing of heavy lag-spikes.

After I set "ScanForIdleHarvestersInterval" to 800, the lag-spikes almost disappear. Although AI also not building harvesters correctly at this point.

If you also confirm that, I guess you have to check the HarvesterBotModuleCA which seems to have very serious performance issue, especially in the late game at certain map.

from camod.

dnqbob avatar dnqbob commented on July 18, 2024

@darkademic

The new Harvester Module still cause lag spikes here but more unpredictable (so I am not certain if it is really causing the lag spikes)

from camod.

darkademic avatar darkademic commented on July 18, 2024

The new Harvester Module still cause lag spikes here but more unpredictable (so I am not certain if it is really causing the lag spikes)

Thanks for the info.

It's pretty strange as I've played multiple hundreds of bot games using the trait (in its old form, and a few in updated form) and not noticed lag spikes like that.

I haven't tried on the map you mentioned though, so can investigate more.

The changes to HarvesterBotModule are pretty small, the AI just counts how many harvesters it has, and compares it to the MaxHarvesters config, to determine whether to produce more, whereas in the normal version it just compares to the number of refineries, so it'd be odd if that caused a major change in performance, though I'm not particularly well versed in C# or game programming.

from camod.

dnqbob avatar dnqbob commented on July 18, 2024

In fact, me neither on those game program.

I happened to find this map, because at that time, I thought protection squad caused the spike lags so a map could trigger protection actions frequently can be good (by minefield at middle and harvester get frequently attacked) . It was very confusing when I found the protection squad was not the cause.

from camod.

dnqbob avatar dnqbob commented on July 18, 2024

It is said found actors in world is a high cost measure, but it is useful and vital to any bot module. We can only use as less as we can.

from camod.

GraionDilach avatar GraionDilach commented on July 18, 2024

The lagspike is expected in the harvester bot module on specific maps. It shouldn't be CA-specific because it shouldn't come from the scanning but from the pathfinder though which is called during assigning idle harvesters to work.

Nonetheless, I have a minor performance optimization suggestion here:

var harvInfo = AIUtils.GetInfoByCommonName(Info.HarvesterTypes, player);
var numHarvesters = AIUtils.CountActorByCommonName(Info.HarvesterTypes, player);
if (numHarvesters >= Info.MaxHarvesters)
return;
var harvCountTooLow = numHarvesters < AIUtils.CountBuildingByCommonName(Info.RefineryTypes, player) * Info.HarvestersPerRefinery;
if (harvCountTooLow && unitBuilder.RequestedProductionCount(bot, harvInfo.Name) == 0)
unitBuilder.RequestUnitProduction(bot, harvInfo.Name);

which I would rewrite to

var numHarvesters = AIUtils.CountActorByCommonName(Info.HarvesterTypes, player);

if (numHarvesters >= Info.MaxHarvesters)
	return;

var harvCountTooLow = numHarvesters < AIUtils.CountBuildingByCommonName(Info.RefineryTypes, player) * Info.HarvestersPerRefinery;
if (!harvCountTooLow )
	return;

var harvInfo = AIUtils.GetInfoByCommonName(Info.HarvesterTypes, player);
if (unitBuilder.RequestedProductionCount(bot, harvInfo.Name) == 0)
	unitBuilder.RequestUnitProduction(bot, harvInfo.Name);

to avoid the iteration on the harvester info on the GetInfoByCommonName call if the end result isn't even used.

from camod.

dnqbob avatar dnqbob commented on July 18, 2024

Therefore, as you can see I drop this AI module on SP AI. I mean the original one.

from camod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.