Skip to content

Improve UnitBuilderBotModule and BaseBuilderBotModule multi-queue performance#20133

Merged
PunkPun merged 4 commits into
OpenRA:bleedfrom
dnqbob:muti-queue
Sep 7, 2023
Merged

Improve UnitBuilderBotModule and BaseBuilderBotModule multi-queue performance#20133
PunkPun merged 4 commits into
OpenRA:bleedfrom
dnqbob:muti-queue

Conversation

@dnqbob

@dnqbob dnqbob commented Jul 19, 2022

Copy link
Copy Markdown
Contributor

UnitBuilderBotModule and BaseBuilderBotModule fix on muti-queue performance:

  1. Only allow new item being queued when cash above a certain number

  2. Only tick one kind of queues at one tick, reduce the pressure on the actived tick

  3. 'BaseBuilderBotModule' will check all buildings in producing, avoid queue mutiple same buildings.

About to make a testcase in cnc mod

@dnqbob

dnqbob commented Jul 22, 2022

Copy link
Copy Markdown
Contributor Author

Note: the AI test case here is the way I making AI for SP and RV.

I add a small cash cheat for AI's Conyers so as AI build more sub-base, they get more resources like human player expand their base for more resources.

this also prevent AI get oneshot by superweapon, making new player have to learn to expand their base and forcus more on squad to win the AI game

@Mailaender Mailaender changed the title UnitBuilderBotModule and BaseBuilderBotModule fix on muti-queue performance Improve UnitBuilderBotModule and BaseBuilderBotModule multi-queue performance Aug 3, 2022
Comment thread OpenRA.Mods.Common/Traits/BotModules/UnitBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/UnitBuilderBotModule.cs Outdated
@dnqbob dnqbob force-pushed the muti-queue branch 2 times, most recently from 73d77c8 to 4811dad Compare August 4, 2022 01:26

@PunkPun PunkPun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review

Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/BaseBuilderQueueManager.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/UnitBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/BaseBuilderQueueManager.cs Outdated
@dnqbob dnqbob force-pushed the muti-queue branch 2 times, most recently from 0b15e09 to c56f1ab Compare August 25, 2022 13:43
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
@dnqbob dnqbob force-pushed the muti-queue branch 2 times, most recently from 1c0a963 to d287ad9 Compare August 25, 2022 14:03
@dnqbob dnqbob marked this pull request as draft August 25, 2022 14:13
@dnqbob

dnqbob commented Aug 25, 2022

Copy link
Copy Markdown
Contributor Author

AI test has problem, will fix it later

Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/UnitBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/BaseBuilderQueueManager.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/UnitBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
@dnqbob dnqbob marked this pull request as ready for review August 26, 2022 02:02
@dnqbob

dnqbob commented Aug 26, 2022

Copy link
Copy Markdown
Contributor Author

Should be all fixed, thanks for the reviews.

Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/BaseBuilderQueueManager.cs Outdated
@dnqbob dnqbob force-pushed the muti-queue branch 2 times, most recently from 9acc6d7 to cbd50f2 Compare July 26, 2023 11:55

@RoosterDragon RoosterDragon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small fixups, but otherwise LGTM.

Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BaseBuilderBotModule.cs Outdated
Comment thread OpenRA.Mods.Common/Traits/BotModules/BotModuleLogic/BaseBuilderQueueManager.cs Outdated

@PunkPun PunkPun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About 2 minutes into a RA game all bots stopped producing anything, no units nor structures

@dnqbob

dnqbob commented Sep 1, 2023

Copy link
Copy Markdown
Contributor Author

Bug confirmed, it is strange that only cnc is normal. Will fix it later.

@dnqbob

dnqbob commented Sep 6, 2023

Copy link
Copy Markdown
Contributor Author

Ok guys, I spoted a wierd bug when I am debugging. I tried output the cash the module used for check, but found the cash get by the module is completely different from the actual cash:
debug

So this is the reason that AI stop producing.

This cash bug happens when the first time AI spend all the cash, and from then on the cash get by module is always 0. I guess it is not the problem of the module here, it should be a commit after this PR broke the related code.

I add a commit to show cash when module check cash.

@PunkPun

@PunkPun

PunkPun commented Sep 6, 2023

Copy link
Copy Markdown
Member

Could it be that it's using cash instead of resources and cash?

@dnqbob

dnqbob commented Sep 6, 2023

Copy link
Copy Markdown
Contributor Author

it is possible.

In addition, We have

(baseBuilder.Info.NewProductionCashThreshold > 0 && playerResources.Resources > baseBuilder.Info.NewProductionCashThreshold

At this place we only use Resources instead of Resources and Cash? Is this place also a problem?

…rmance:

1. Only allow new item being queued when cash above a certain number

2. Only tick one kind of queues at one tick, reduce the pressure on the actived tick

3. 'BaseBuilderBotModule' will check all buildings in producing, avoid queue mutiple same buildings.
@dnqbob

dnqbob commented Sep 6, 2023

Copy link
Copy Markdown
Contributor Author

Add GetCashAndResources() to make the code more understandable on where use Cash + Resources.

Also fix NewProductionCashThreshold only use resources

@PunkPun PunkPun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

GetCashAndResources() will be superseded by the pending resource refactor, though it will be easy to deprecate

@PunkPun PunkPun merged commit fb55f28 into OpenRA:bleed Sep 7, 2023
@PunkPun

PunkPun commented Sep 7, 2023

Copy link
Copy Markdown
Member

Changelog

@dnqbob dnqbob deleted the muti-queue branch September 7, 2023 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants