private void OnTriggerExit(Collider other) { TennisArea area = areaObject.GetComponent <TennisArea>(); TennisAgent agentA = area.agentA.GetComponent <TennisAgent>(); TennisAgent agentB = area.agentB.GetComponent <TennisAgent>(); if (other.name == "over") { if (lastAgentHit == 0) { agentA.AddReward(0.1f); } else { agentB.AddReward(0.1f); } lastAgentHit = 0; } }
private void OnTriggerExit(Collider other) { if (other.name == "over") { if (lastAgentHit == 0) { m_AgentA.AddReward(0.1f); } else { m_AgentB.AddReward(0.1f); } lastAgentHit = 0; } }
private void OnTriggerExit(Collider other) { debugAward("Start - Over the net"); if (other.name == "over") { switch (lastAgentHit) { case 0: agentA1.AddReward(0.1f); agentA2.AddReward(0.1f); break; case 1: agentA1.AddReward(0.1f); agentA2.AddReward(0.1f); break; case 2: agentB1.AddReward(0.1f); agentB2.AddReward(0.1f); break; case 3: agentB1.AddReward(0.1f); agentB2.AddReward(0.1f); break; } } debugAward("End - Over the net"); }
private void OnCollisionEnter(Collision collision) { TennisArea area = areaObject.GetComponent <TennisArea>(); TennisAgent agentA = area.agentA.GetComponent <TennisAgent>(); TennisAgent agentB = area.agentB.GetComponent <TennisAgent>(); if (collision.gameObject.tag == "iWall") { if (collision.gameObject.name == "wallA") { if (lastAgentHit == 0) { agentA.AddReward(-0.01f); agentB.SetReward(0); agentB.score += 1; } else { agentA.SetReward(0); agentB.AddReward(-0.01f); agentA.score += 1; } } else if (collision.gameObject.name == "wallB") { if (lastAgentHit == 0) { agentA.AddReward(-0.01f); agentB.SetReward(0); agentB.score += 1; } else { agentA.SetReward(0); agentB.AddReward(-0.01f); agentA.score += 1; } } else if (collision.gameObject.name == "floorA") { if (lastAgentHit == 0 || lastAgentHit == -1) { agentA.AddReward(-0.01f); agentB.SetReward(0); agentB.score += 1; } else { agentA.AddReward(-0.01f); agentB.SetReward(0); agentB.score += 1; } } else if (collision.gameObject.name == "floorB") { if (lastAgentHit == 1 || lastAgentHit == -1) { agentA.SetReward(0); agentB.AddReward(-0.01f); agentA.score += 1; } else { agentA.SetReward(0); agentB.AddReward(-0.01f); agentA.score += 1; } } else if (collision.gameObject.name == "net") { if (lastAgentHit == 0) { agentA.AddReward(-0.01f); agentB.SetReward(0); agentB.score += 1; } else { agentA.SetReward(0); agentB.AddReward(-0.01f); agentA.score += 1; } } agentA.Done(); agentB.Done(); area.MatchReset(); } if (collision.gameObject.tag == "agent") { if (collision.gameObject.name == "AgentA") { lastAgentHit = 0; } else { lastAgentHit = 1; } } }