public void BulletCallback(bool timedOut, Collision other) { // Should start low and increase later in training. const float wasteAmmoPenalty = 0.1f; if (timedOut) { AddReward(-wasteAmmoPenalty); } else if (other.gameObject.CompareTag("Agent")) { AdvancedAgent agent = other.gameObject.GetComponent <AdvancedAgent>(); if (agent.IsTeamA == IsTeamA) { // TODO Too many friendly fire hits. AddReward(-0.5f); } else { AddReward(1f); agent.AddReward(-1f); } } else { // Asteroid. AddReward(-wasteAmmoPenalty); } }
public void Shoot(AdvancedAgent shooter, float offset = 3f) { Transform t = shooter.transform; Vector3 fwd = t.forward; Bullet bullet = Spawn(); bullet.transform.position = t.position + fwd * offset; bullet.Callback = shooter.BulletCallback; bullet.Shoot(fwd, shooter.IsTeamA); if (active.ContainsKey(bullet)) { // TODO should never contain bullet here. active.Remove(bullet); } active.Add(bullet, t); }
public void StartDemoAgent(int gameId, bool advanced) { if (advanced) { var agentTask = Task.Factory.StartNew(async() => { var sweetDemoAgent = new AdvancedAgent(gameId); await sweetDemoAgent.Start(); }); } else { var agentTask = Task.Factory.StartNew(async() => { var sweetDemoAgent = new Agent(gameId); await sweetDemoAgent.Start(); }); } }
public Opponent(AdvancedAgent agent) { Agent = agent; }