示例#1
0
    void FixedUpdate()
    {
        m_ResetTimer += 1;
        if (m_ResetTimer >= MaxEnvironmentSteps && MaxEnvironmentSteps > 0)
        {
            m_AgentGroup.GroupEpisodeInterrupted();
            ResetScene();
        }

        //Hurry Up Penalty
        m_AgentGroup.AddGroupReward(-0.5f / MaxEnvironmentSteps);
    }
示例#2
0
 public void GoalTouched(Team scoredTeam)
 {
     if (scoredTeam == Team.Blue)
     {
         m_BlueAgentGroup.AddGroupReward(1 - m_ResetTimer / MaxEnvironmentSteps);
         m_PurpleAgentGroup.AddGroupReward(-1);
     }
     else
     {
         m_PurpleAgentGroup.AddGroupReward(1 - m_ResetTimer / MaxEnvironmentSteps);
         m_BlueAgentGroup.AddGroupReward(-1);
     }
     m_PurpleAgentGroup.EndGroupEpisode();
     m_BlueAgentGroup.EndGroupEpisode();
     ResetScene();
 }
示例#3
0
 public void GoalTouched(Team scoredTeam)
 {
     if (scoredTeam == Team.Blue)
     {
         TeamBlue.AddGroupReward(1 - timer / MaxEnvironmentSteps);
         TeamRed.AddGroupReward(-1);
     }
     else
     {
         m_TeamRed.AddGroupReward(1 - timer / MaxEnvironmentSteps);
         TeamRed.AddGroupReward(-1);
     }
     TeamBlue.EndGroupEpisode();
     TeamRed.EndGroupEpisode();
     ResetScene();
 }
        public void TestRegisterMultipleAgent()
        {
            var agentGo1 = new GameObject("TestAgent");

            agentGo1.AddComponent <TestAgent>();
            var agent1   = agentGo1.GetComponent <TestAgent>();
            var agentGo2 = new GameObject("TestAgent");

            agentGo2.AddComponent <TestAgent>();
            var agent2 = agentGo2.GetComponent <TestAgent>();

            SimpleMultiAgentGroup agentGroup = new SimpleMultiAgentGroup();

            agentGroup.RegisterAgent(agent1);   // register
            Assert.AreEqual(agentGroup.GetRegisteredAgents().Count, 1);
            agentGroup.UnregisterAgent(agent2); // unregister non-member agent
            Assert.AreEqual(agentGroup.GetRegisteredAgents().Count, 1);
            agentGroup.UnregisterAgent(agent1); // unregister
            Assert.AreEqual(agentGroup.GetRegisteredAgents().Count, 0);
            agentGroup.RegisterAgent(agent1);
            agentGroup.RegisterAgent(agent1); // duplicated register
            Assert.AreEqual(agentGroup.GetRegisteredAgents().Count, 1);
            agentGroup.RegisterAgent(agent2); // register another
            Assert.AreEqual(agentGroup.GetRegisteredAgents().Count, 2);

            // test add/set group rewards
            agentGroup.AddGroupReward(0.1f);
            Assert.AreEqual(0.1f, agent1._GroupReward);
            agentGroup.AddGroupReward(0.5f);
            Assert.AreEqual(0.6f, agent1._GroupReward);
            agentGroup.SetGroupReward(0.3f);
            Assert.AreEqual(0.3f, agent1._GroupReward);
            // unregistered agent should not receive group reward
            agentGroup.UnregisterAgent(agent1);
            agentGroup.AddGroupReward(0.2f);
            Assert.AreEqual(0.3f, agent1._GroupReward);
            Assert.AreEqual(0.5f, agent2._GroupReward);

            // dispose group should automatically unregister all
            agentGroup.Dispose();
            Assert.AreEqual(0, agent1._GroupId);
            Assert.AreEqual(0, agent2._GroupId);
        }
    public void UnlockDoor()
    {
        m_AgentGroup.AddGroupReward(1f);
        StartCoroutine(GoalScoredSwapGroundMaterial(m_PushBlockSettings.goalScoredMaterial, 0.5f));

        print("Unlocked Door");
        m_AgentGroup.EndGroupEpisode();

        ResetScene();
    }
 public void CarFinished(MLCar carId)
 {
     m_AgentGroup.AddGroupReward(1f);
     CarDisable(carId);
 }