|
|
|
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using Unity.MLAgents.Extensions.MultiAgent; |
|
|
|
using Unity.MLAgents; |
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
public class PushBlockEnvController : MonoBehaviour |
|
|
|
|
|
|
|
|
|
|
private int m_NumberOfRemainingBlocks; |
|
|
|
|
|
|
|
private BaseMultiAgentGroup m_AgentGroup; |
|
|
|
private SimpleMultiAgentGroup m_AgentGroup; |
|
|
|
|
|
|
|
private int m_ResetTimer; |
|
|
|
|
|
|
|
|
|
|
item.Rb = item.T.GetComponent<Rigidbody>(); |
|
|
|
} |
|
|
|
// Initialize TeamManager
|
|
|
|
m_AgentGroup = new BaseMultiAgentGroup(); |
|
|
|
m_AgentGroup = new SimpleMultiAgentGroup(); |
|
|
|
foreach (var item in AgentsList) |
|
|
|
{ |
|
|
|
item.StartingPos = item.Agent.transform.position; |
|
|
|
|
|
|
col.gameObject.SetActive(false); |
|
|
|
|
|
|
|
//Give Agent Rewards
|
|
|
|
foreach (var item in AgentsList) |
|
|
|
{ |
|
|
|
item.Agent.AddReward(score); |
|
|
|
} |
|
|
|
m_AgentGroup.AddGroupReward(score); |
|
|
|
|
|
|
|
// Swap ground material for a bit to indicate we scored.
|
|
|
|
StartCoroutine(GoalScoredSwapGroundMaterial(m_PushBlockSettings.goalScoredMaterial, 0.5f)); |
|
|
|