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

AI Update V8 #3114

Merged
merged 9 commits into from
Aug 10, 2020
Merged

AI Update V8 #3114

merged 9 commits into from
Aug 10, 2020

Conversation

Uveso
Copy link
Contributor

@Uveso Uveso commented May 25, 2020

(Rebased 25.May)
(Rebased 10.Aug)

Finally this patch will fix the game slowdown on long AI games.
Reason for the slowdown was the engineermanger while ping pong forking functions.
This was causing in the end a engine slowdown a finally a stack buffer overrun.

This patch also stores almost every forked thread to the corresponding unit/weapon,
so it can be destroyed on unit dead to prevent parentless threads.

The transport function is now using surfaceghight for the transportation target
for faster unit drops.

Also fixed an issue where the ACU is not moving on gamestart.
This was caused by the BlockCommandQueue from the ACU WarpInAnimation

Changelog: (updated 11.Aug)


CAiBrain.lua

-Upd: fixed/updated some function information


aiarchetype-managerloader.lua

function ExecutePlan()
-Opt: Storing Forked Thread inside the aiBrain Trashbag for better performance


AIBehaviors.lua

function CommanderThread()
-Opt: Added check for 'BlockCommandQueue' to prevent stucked ACU after WarpInAnimation

function CommanderThreadImproved()
-Opt: Added check for 'BlockCommandQueue' to prevent stucked ACU after WarpInAnimation

function GetClosestShieldProtectingTarget()
-Opt: Added safeguard for dead attacker or target

function CommanderThreadSorian()
-Opt: Added check for 'BlockCommandQueue' to prevent stucked ACU after WarpInAnimation


SorianStrategyBuilders.lua

BuilderGroup 'Sorian Excess Mass Strategy'
-Opt: Storing Forked Thread inside the aiBrain Trashbag for better performance


AttackManager.lua

function FormAttackPlatoon()
-Opt: Storing Forked Thread inside the aiBrain Trashbag for better performance


aiutilities.lua

function UseTransports()
-Opt: Changed command WaitTicks() to coroutine.yield() for better performance
-Opt: Added surfacehight to trasnport location for faster unit unloading

function EngineerTryReclaimCaptureArea()
-Fix: Function now only returns true if we have valid unit for capture

function UseTransports
-Fix: Added IssueClearCommands for transports to prevent flightloops


sorianutilities.lua

function Nuke()
-Opt: Storing Forked Thread inside the aiBrain Trashbag for better performance


aibrain.lua

function AddBuilderManagers()
-Opt: Added a baseType to every expansion for faster expansion count

function GetManagerCount()
-Opt: To count expansions we are now searching for a baseType not 8 x name search

function InitialAIThread
-Fix: Delaying the AI so it can't reclaim the start area before it's cleared from the ACU landing blast.

function OnCreateAI
-Fix: removed AI-Uveso and AI-Dilli identifier (will be set from the AI mods now)

function OnDefeat
-Fix: Propper removing of AI threads and managers at game end.


BuilderManager.lua

function SortBuilderList
-Fix: Buiulder with priorty 0 will no longer ignored on sorting the builderlist


cybranunits.lua

Class CConstructionEggUnit()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance


aiattackutilities.lua

function GetBestThreatTarget()
-Fix: changed missplaced variables in GetThreatAtPosition call


defaultunits.lua

function OnPrepareArmToBuild() (ConstructionUnit Class)
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance

function OnPrepareArmToBuild() (CommandUnit Class)
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance


platoon.lua

several functions()
-Opt: Changed command WaitTicks() to coroutine.yield() for better performance

function AssistBody()
-Opt: Moved safeguard for nonexisting platoons at the start of the function

function EngineerBuildAI()
-Opt: Removed old sorianfunction for delaying platoonbuilder
-Fix: Excluded StationAssitPods from building tasks
-Opt: Using now .Location instead of the functioncall :GetLocationCoords()
-Fix: The safeguard at the end of the function is now working

function WatchForNotBuilding()
-Opt: Removed unused unitstate checks

function ProcessBuildCommand()
-Opt: replaced BuildToNormalLocation and NormalToBuildLocation and used numbers directly
-Fix: Units now get capture/reclaim and buildcommands queued instead of looping the ProcessBuildCommand
-Fix: Prevent disbanding a platoon while on a transport

function EngineerBuildAISorian
-Opt: Removed old sorianfunction for delaying platoonbuilder
-Opt: Using now .Location instead of the functioncall :GetLocationCoords()


ScenarioUtilities.lua

function CommanderWarpDelay()
-Opt: Removed BlockCommandQueue for AI brains


EngineerManager.lua

several functions()
-Opt: Changed command WaitTicks() to coroutine.yield() for better performance

function AddUnit()
-Fix: Excluded StationAssitPods from building tasks
-Fix: Changed the logic of forking threads to prevent gameslowdown at +1 hour

function GetNumCategoryBeingBuilt()
-Opt: returning a value directly without defining it local

function TaskFinished()
-Fix: Changed the logic of forking threads to prevent gameslowdown at +1 hour

function ManagerLoopBody
-Del: removed the function (was a leftover from sorians strategy manager)

Removed functions:
EngineerWaiting, InitialWait, DelayAssign, DelayAssignBody
-Fix: Changed the logic of forking threads to prevent gameslowdown at +1 hour

Replaced removed functiosn with new functions:
ForkEngineerTask, DelayAssign, Wait, EngineerWaiting
-Fix: Changed the logic of forking threads to prevent gameslowdown at +1 hour


Unit.lua

function DeathThread()
-Opt: Destroy trashbags only if not already done

function DestroyAllTrashBags()
-New: This function clears all trashbags and unit effects

function OnDestroy()
-New: Destroy trashbags only if not already done inside DeathThread()

function StopRocking()
-Opt: Only kill a thread when it actual exist.


Blueprints.lua

function HandleUnitWithBuildPresets()
-New: Adding SACU presets as unit category for AI builders


UEL0001_script.lua

function CreateEnhancement()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance


UEL0301_script.lua

function CreateEnhancement()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance


XRB2308_script.lua

function OnStopBeingBuilt()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance

function StartSinking()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance


XRB2309_script.lua

function StartSinking()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance

@Uveso Uveso changed the title AI Update V8 - Rebased AI Update V8 - Rebased DO NOT MERGE! (more updates are on the way) May 30, 2020
@Uveso Uveso changed the title AI Update V8 - Rebased DO NOT MERGE! (more updates are on the way) AI Update V8 Jun 3, 2020
@shalkya shalkya added this to the 3713 milestone Jun 18, 2020
Finally this patch will fix the game slowdown on long AI games.
Reason for the slowdown was the engineermanger while ping pong forking functions.
This was causing in the end a engine slowdown a finally a stack buffer overrun.

This patch also stores almost every forked thread to the corresponding unit/weapon,
so it can be destroyed on unit dead to prevent parentless threads.

The transport function is now using surfaceghight for the transportation target
for faster unit drops.

Also fixed an issue where the ACU is not moving on gamestart.
This was caused by the `BlockCommandQueue` from the ACU WarpInAnimation

Changelog:

------------------------------------------------------------------------------------

aiarchetype-managerloader.lua

function ExecutePlan()
-Opt: Storing Forked Thread inside the aiBrain Trashbag for better performance

------------------------------------------------------------------------------------

AIBehaviors.lua

function CommanderThread()
-Opt: Added check for 'BlockCommandQueue' to prevent stucked ACU after WarpInAnimation

function CommanderThreadImproved()
-Opt: Added check for 'BlockCommandQueue' to prevent stucked ACU after WarpInAnimation

function GetClosestShieldProtectingTarget()
-Opt: Added safeguard for dead attacker or target

function CommanderThreadSorian()
-Opt: Added check for 'BlockCommandQueue' to prevent stucked ACU after WarpInAnimation

------------------------------------------------------------------------------------

SorianStrategyBuilders.lua

BuilderGroup 'Sorian Excess Mass Strategy'
-Opt: Storing Forked Thread inside the aiBrain Trashbag for better performance

------------------------------------------------------------------------------------

AttackManager.lua

function FormAttackPlatoon()
-Opt: Storing Forked Thread inside the aiBrain Trashbag for better performance

------------------------------------------------------------------------------------

aiutilities.lua

function UseTransports()
-Opt: Changed command WaitTicks() to coroutine.yield() for better performance
-Opt: Added surfacehight to trasnport location for faster unit unloading

function EngineerTryReclaimCaptureArea()
-Fix: Function now only returns true if we have valid unit for capture

function UseTransports
-Fix: Added IssueClearCommands for transports to prevent flightloops

------------------------------------------------------------------------------------

sorianutilities.lua

function Nuke()
-Opt: Storing Forked Thread inside the aiBrain Trashbag for better performance

------------------------------------------------------------------------------------

aibrain.lua

function AddBuilderManagers()
-Opt: Added a baseType to every expansion for faster expansion count

function GetManagerCount()
-Opt: To count expansions we are now searching for a baseType not 8 x name search

function InitialAIThread
-Fix: Delaying the AI so it can't reclaim the start area before it's cleared from the ACU landing blast.

------------------------------------------------------------------------------------

cybranunits.lua

Class CConstructionEggUnit()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance

------------------------------------------------------------------------------------

aiattackutilities.lua

function GetBestThreatTarget()
-Fix: changed missplaced variables in GetThreatAtPosition call

------------------------------------------------------------------------------------
defaultunits.lua

function OnPrepareArmToBuild() (ConstructionUnit Class)
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance

function OnPrepareArmToBuild() (CommandUnit Class)
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance

------------------------------------------------------------------------------------

platoon.lua

several functions()
-Opt: Changed command WaitTicks() to coroutine.yield() for better performance

function AssistBody()
-Opt: Moved safeguard for nonexisting platoons at the start of the function

function EngineerBuildAI()
-Opt: Removed old sorianfunction for delaying platoonbuilder
-Fix: Excluded StationAssitPods from building tasks
-Opt: Using now .Location instead of the functioncall :GetLocationCoords()
-Fix: The safeguard at the end of the function is now working

function WatchForNotBuilding()
-Opt: Removed unused unitstate checks

function ProcessBuildCommand()
-Opt: replaced BuildToNormalLocation and NormalToBuildLocation and used numbers directly
-Fix: Units now get capture/reclaim and buildcommands queued instead of looping the ProcessBuildCommand
-Fix: Prevent disbanding a platoon while on a transport

function EngineerBuildAISorian
-Opt: Removed old sorianfunction for delaying platoonbuilder
-Opt: Using now .Location instead of the functioncall :GetLocationCoords()

------------------------------------------------------------------------------------

ScenarioUtilities.lua

function CommanderWarpDelay()
-Opt: Removed BlockCommandQueue for AI brains

------------------------------------------------------------------------------------

EngineerManager.lua

several functions()
-Opt: Changed command WaitTicks() to coroutine.yield() for better performance

function AddUnit()
-Fix: Excluded StationAssitPods from building tasks
-Fix: Changed the logic of forking threads to prevent gameslowdown at +1 hour

function GetNumCategoryBeingBuilt()
-Opt: returning a value directly without defining it local

function TaskFinished()
-Fix: Changed the logic of forking threads to prevent gameslowdown at +1 hour

Removed functions:
EngineerWaiting, InitialWait, DelayAssign, DelayAssignBody
-Fix: Changed the logic of forking threads to prevent gameslowdown at +1 hour

Replaced removed functiosn with new functions:
ForkEngineerTask, DelayAssign, Wait, EngineerWaiting
-Fix: Changed the logic of forking threads to prevent gameslowdown at +1 hour

------------------------------------------------------------------------------------

Unit.lua

function DeathThread()
-Opt: Destroy trashbags only if not already done

function DestroyAllTrashBags()
-New: This function clears all trashbags and unit effects

function OnDestroy()
-New: Destroy trashbags only if not already done inside DeathThread()

function StopRocking()
-Opt: Only kill a thread when it actual exist.

------------------------------------------------------------------------------------

Blueprints.lua

function HandleUnitWithBuildPresets()
-New: Adding SACU presets as unit category for AI builders

------------------------------------------------------------------------------------

CIFArtilleryProton01_script.lua

function OnImpact()
-Opt: Storing Forked Thread inside the Projectile Trashbag for better performance

------------------------------------------------------------------------------------

UEL0001_script.lua

function CreateEnhancement()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance

------------------------------------------------------------------------------------

UEL0301_script.lua

function CreateEnhancement()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance

------------------------------------------------------------------------------------

XRB2308_script.lua

function OnStopBeingBuilt()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance

function StartSinking()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance

------------------------------------------------------------------------------------

XRB2309_script.lua

function StartSinking()
-Opt: Storing Forked Thread inside the Unit Trashbag for better performance
Update for debug log,
patch for ProcessBuildCommand
(engineers first move to the destination and then decide if they need reclaim or capture.)
Platoons with priority 0 got deleted by the SortBuilderList function,
but we need them running to check the priority function.
leftover from sorian strategy manager
happens often when noRush is activated
@shalkya shalkya merged commit 8ae4eca into FAForever:deploy/fafdevelop Aug 10, 2020
@Uveso Uveso deleted the AIUpdateV8 branch January 4, 2021 08:55
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.

2 participants