Learning Agents issue with SetupCompletions

Marsal02
Sun, 04 May 2025 18:27:29 +0000
C++

Hi so I am trying to create an AI that would be basically an Enemy archer that would learn how to shoot enemies that are moving continuously in a room I am using Learning Agents on 5.3.2, also using C++. My issue is that it will generate the first iteration results, it will run a little bit more, and will give me this error: Agent with id x has completed episode and will be reset but has not generated any experience. I am having like 7 agents. This is how my SetupCompletion looks like:

void ULearningAgentsTrainerR::SetupCompletions_Implementation()
{
    TimeCompletion = UTimeElapsedCompletion::AddTimeElapsedCompletion(
        this,
        FName("TimeCompletion"),
        30.0f,
        ELearningAgentsCompletion::Truncation
    );
}

And this is my SetCompletions implementation:

void ULearningAgentsTrainerR::SetCompletions_Implementation(const TArray<int32>& AgentIds)
{
    for (int32 AgentId : AgentIds)
    {
        float& Timer = EpisodeTimers.FindOrAdd(AgentId);
        Timer += GetWorld()->DeltaTimeSeconds;
        TimeCompletion->SetTimeElapsedCompletion(AgentId, Timer);
    }
}

And basically the error will get spammed, and my ResetAgents method will get called everytime, which basically will teleport my enemies continuously. I would really appreciate your help, really don’t know how to implement this SetupCompletions and SetCompletions, if you have any advice, it would be verry apreaciated.

2 posts - 2 participants