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

Add support for small state machines for AI #4748

Closed
wants to merge 2 commits into from

Conversation

Garanas
Copy link
Member

@Garanas Garanas commented Feb 26, 2023

No description provided.

@Garanas Garanas added area: sim Area that is affected by the Simulation of the Game area: ui Anything to do with the User Interface of the Game area: AI related to AI functions labels Feb 26, 2023
@Garanas Garanas added this to the Development iteration II milestone Feb 26, 2023
@Garanas Garanas marked this pull request as draft February 26, 2023 20:03
@relent0r
Copy link
Contributor

Jip are you able to provide a little blurb on how an AI dev would initialize a state machine from the skirmish AI? I'm only used to getting platoons to do things via the platoon former manager.

@Garanas
Copy link
Member Author

Garanas commented Feb 26, 2023

@relent0r can you show me where the current platoon AI is applied to a platoon?

@relent0r
Copy link
Contributor

The current entry point is here.

ManagerLoopBody = function(self,builder,bType)

So we assume that the Builder has passed all the requirements. It hits this, sets a few bits. Then checks if it can form the platoon based on the template provided and the units available using the CanFormPlatoon. Then it uses the FormPlatoon function and does a SetAIPlan based on the function in the platoontemplate's Plan property, it will fork a function within the platoon.lua file.
Then if there are any addons or behaviors it does that afterwards.

@ageekhere
Copy link

Some suggestions

        self.Identifier = string.format("Default - %d", GetUniqueIdentifier()) --removed self.Identifier, it may be unnecessary? 
	--move local to top
	--use pairs
	ToSync = function(self, key, value)
        local tick = GetGameTick()
        local syncState = self.StateSync
		local sync = Sync
        local syncStateMachines = sync.StateMachines or {}
        if syncState.Tick < tick then
            for k,v in pairs(syncState) do 
                syncState[k] = nil
            end
            syncState.Tick = tick
        end

    end,

@Garanas
Copy link
Member Author

Garanas commented Feb 27, 2023

@ageekhere we're not at the phase to optimize yet, first rule of improving the performance of any snippet of code is to have it functional first 😉

@Garanas
Copy link
Member Author

Garanas commented May 18, 2023

Closed in favor of the one introduced by #4858

@Garanas Garanas closed this May 18, 2023
@Garanas Garanas deleted the feature/state-machine-ai branch June 20, 2023 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: AI related to AI functions area: sim Area that is affected by the Simulation of the Game area: ui Anything to do with the User Interface of the Game
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants