MA-PCOA for multi-agent learning, group reward is updated only once for the first time, and then it

I am using MA-PCOA for multi-agent learning,
group reward is updated only once for the first time, and then it keeps coming back to 0.
7561069--935326--upload_2021-10-10_18-59-16.jpeg
I am attaching my code below. Help

using System.Collections.Generic;
using Unity.MLAgents;
using UnityEngine;
using System.Collections;

public class WTAEnvController : MonoBehaviour
{
[System.Serializable]
public class PlayerInfo
{

public ShootingAgent Agent;
[HideInInspector]
public Vector3 StartingPos;
[HideInInspector]
public Quaternion StartingRot;
[HideInInspector]
public Rigidbody Rb;
//public int TeamID;
}

public ShootingAgent ShootingAgent;

///


/// Max Academy steps before this platform resets
///

///
public int MaxEnvironmentSteps = 25000;
public int count_blue_victory = 0;
public int count_red_victory = 0;

//public List Team0Players;
//public List Team1Players;

//List of Agents On Platform
public List AgentsList = new List();
private ShootingSettings m_ShootingSettings;
public SimpleMultiAgentGroup m_BlueAgentGroup;
public SimpleMultiAgentGroup m_RedAgentGroup;
private int m_ResetTimer;
void Start()
{

m_ShootingSettings = FindObjectOfType();
// Initialize TeamManager
m_BlueAgentGroup = new SimpleMultiAgentGroup();
m_RedAgentGroup = new SimpleMultiAgentGroup();
foreach (var item in AgentsList)
{
item.StartingPos = item.Agent.transform.position;
item.StartingRot = item.Agent.transform.rotation;
item.Rb = item.Agent.GetComponent();
if (item.Agent.team == Team.Blue)
{
m_BlueAgentGroup.RegisterAgent(item.Agent);
}
else
{
m_RedAgentGroup.RegisterAgent(item.Agent);
}
}
ResetScene();
}

void FixedUpdate()
{
m_ResetTimer += 1;
if (m_ResetTimer >= MaxEnvironmentSteps)
{
m_BlueAgentGroup.GroupEpisodeInterrupted();
m_RedAgentGroup.GroupEpisodeInterrupted();
ResetScene();
}
GameObject[ ] num_red; // enemy 빈 집합
GameObject[ ] num_blue; // agents 빈 집합
num_red = GameObject.FindGameObjectsWithTag(“enemy”);
num_blue = GameObject.FindGameObjectsWithTag(“agent”);

if (num_red.Length == 0) // red team 전멸
{
Debug.Log(“Blue is Victory”);
count_blue_victory++;
Debug.Log(count_blue_victory);
Victory(Team.Blue);
}

if (num_blue.Length == 0) // blue team 전멸
{
count_red_victory++;
Debug.Log(“Red is Victory”);
Debug.Log(count_red_victory);
Victory(Team.Red);
}

}

public void Victory(Team victoryTeam)
{
if (victoryTeam == Team.Blue)
{
Debug.Log(“Team.Blue get Reward”);
m_BlueAgentGroup.AddGroupReward(1 - m_ResetTimer / MaxEnvironmentSteps);
m_RedAgentGroup.AddGroupReward(-1);

}
if (victoryTeam == Team.Red)
{
Debug.Log(“Team.Red is Reward”);
m_RedAgentGroup.AddGroupReward(1 - m_ResetTimer / MaxEnvironmentSteps);
m_BlueAgentGroup.AddGroupReward(-1);

}

m_RedAgentGroup.EndGroupEpisode();
m_BlueAgentGroup.EndGroupEpisode();
ResetScene();

}

void ResetScene()
{
Debug.Log(“Reset Agents”);
m_ResetTimer = 0;
foreach (var item in AgentsList)
{

item.Agent.Inf_startingHealth = 100;
item.Agent.Art_startingHealth = 500;
var newStartPos = item.StartingPos;
var newRot = item.StartingRot;
item.Agent.Rb.velocity = Vector3.zero;
item.Agent.ShotAvaliable = true;
item.Agent.transform.SetPositionAndRotation(newStartPos, newRot);
item.Agent.gameObject.SetActive(true);

}

}
}

6741043--776845--upload_2021-1-19_19-3-0.png

  • I have the same problem. Have you solved it