void KeepAgentInSceneExtents(NeuralNetworkAgent agent)
        {
            Vector3 position = agent.transform.position;

            if (position.x > transform.position.x + sceneHalfExtents.x)
            {
                position.x -= sceneHalfExtents.x * 2f;
            }
            else
            if (position.x < transform.position.x - sceneHalfExtents.x)
            {
                position.x += sceneHalfExtents.x * 2f;
            }

            if (position.z > transform.position.x + sceneHalfExtents.z)
            {
                position.z -= sceneHalfExtents.z * 2f;
            }
            else
            if (position.z < transform.position.x - sceneHalfExtents.z)
            {
                position.z += sceneHalfExtents.z * 2f;
            }

            agent.transform.position = position;
        }
        NeuralNetworkAgent CreateAgent(Genome genome, NeuralNetwork neuralNetwork)
        {
            GameObject         go    = Instantiate(agentPrefab, GetRandomPosition(), GetRandomRotation());
            NeuralNetworkAgent agent = go.GetComponent <NeuralNetworkAgent>();

            agent.SetNeuralNetwork(genome, neuralNetwork);

            return(agent);
        }
Beispiel #3
0
        protected override void OnSimulationAgentUpdate(NeuralNetworkAgent agent)
        {
            MinerTankAgent minerTankAgent = agent as MinerTankAgent;

            GameObject mine = GetNearestMine(minerTankAgent.transform.position);

            minerTankAgent.NearestMine = mine;

            minerTankAgent.Think();
        }
        protected override void OnSimulationAgentUpdate(NeuralNetworkAgent agent)
        {
            TurretTankAgent turretTankAgent = agent as TurretTankAgent;

            if (!turretTankAgent.HasFired)
            {
                Collider enemy = GetNearestEnemy(turretTankAgent.transform);
                turretTankAgent.NearestEnemy = enemy;
            }
            else
            {
                turretTankAgent.UpdateCurrentProjectiles();
                turretTankAgent.UpdateFiringCooldown();
            }

            turretTankAgent.Think();
        }
 protected abstract void OnSimulationAgentUpdate(NeuralNetworkAgent agent);