示例#1
0
        public void GenerateHighlightInfoTest()
        {
            var deepLearner = new NeuralNetController();

            highlightInfo = deepLearner.GetHighlightPeriod(matchCollection[0], true);

            // Assert highlightInfo correct.
            Assert.True(highlightInfo.Score > 0.75);
            Assert.True(highlightInfo.StartOffset > 7400);
            Assert.True(File.Exists(TestHelper.tensorflowDataPath + "Predictions\\" + matchCollection[0].Match.BroadcastId + "match1_prediction.csv"));
        }
示例#2
0
    public float[] RandomInputBuilder(NeuralNetController controller)
    {
        var retFloat = new float[controller.numOfInput];

        for (int i = 0; i < controller.numOfInput; i++)
        {
            retFloat[i] = Random.value;
        }

        return(retFloat);
    }
示例#3
0
    public float[] RandomInputBuilder(NeuralNetController controller)
    {
        var retFloat = new float[controller.numOfInput];

        for (int i = 0; i < controller.numOfInput; i++)
        {
            retFloat[i] = Random.value;
        }

        return retFloat;
    }
示例#4
0
    public void spawnAI()
    {
        if (!GameManager.GM.RoundBegin)
        {
            if (UseNetwork)
            {
                NeuralNetController myNet   = NeuralNetController.NNC;
                int        NetworkAiToSpawn = Mathf.RoundToInt(Mathf.Lerp(MinAIToSpawn, MaxAIToSpawn, myNet.Outputs[(int)NetworkOutputNames.NumAi]));
                int        DetectionRadius  = Mathf.RoundToInt(Mathf.Lerp(MinDetectionRadius, MaxDetectionRadius, myNet.Outputs[(int)NetworkOutputNames.DetectionRadius]));
                bool       CanAim           = myNet.Outputs[(int)NetworkOutputNames.CanAim] > 0.5f;
                float      Accuracy         = Mathf.Lerp(MinAccuracy, MaxAccuracy, myNet.Outputs[(int)NetworkOutputNames.Accuracy]);
                int        numGoals         = Mathf.RoundToInt(Mathf.Lerp(1, 4, myNet.Outputs[(int)NetworkOutputNames.Goals]));
                BaseWeapon WeaponForAI      = Weapons[Mathf.RoundToInt(Mathf.Lerp(0, Weapons.Count - 1, myNet.Outputs[(int)NetworkOutputNames.Weapon]))];
                float      MaxHealth        = Mathf.Lerp(50, 200, myNet.Outputs[(int)NetworkOutputNames.MaxHealth]);

                for (int i = 0; i < NetworkAiToSpawn; ++i)
                {
                    // Get Position within Next Area.
                    GameObject nAI       = Instantiate(AIPrefab, GetRandomPosition(), Quaternion.identity, transform);
                    GoapAgent  tempAgent = nAI.GetComponent <GoapAgent>();
                    AddGoals(ref tempAgent, numGoals);

                    GoapAI myAIComp = nAI.GetComponent <GoapAI>();
                    myAIComp.DetectionRadius = DetectionRadius;
                    myAIComp.CanAimWeapon    = CanAim;
                    myAIComp.LookAccuracy    = Accuracy;
                    myAIComp.AddWeapon(WeaponForAI);
                    myAIComp.myDetectionObj.GetComponent <SphereCollider>().radius = DetectionRadius;

                    Health AIHealth = nAI.GetComponent <Health>();
                    AIHealth.MaxHealth = MaxHealth;

                    SpawnedAI.Add(myAIComp);
                    tempAgent.Initialise();
                    myAIComp.Initialise();
                }

                GameManager.GM.AIRemaining = NetworkAiToSpawn;
                GameManager.GM.RoundBegin  = true;
                GameManager.GM.UpdateAICount();
            }
        }
    }
示例#5
0
    void UpdateCurrentAI()
    {
        if (GameManager.GM.RoundBegin)
        {
            NeuralNetController myNet   = NeuralNetController.NNC;
            int        NetworkAiToSpawn = Mathf.RoundToInt(Mathf.Lerp(MinAIToSpawn, MaxAIToSpawn, myNet.Outputs[(int)NetworkOutputNames.NumAi]));
            int        DetectionRadius  = Mathf.RoundToInt(Mathf.Lerp(MinDetectionRadius, MaxDetectionRadius, myNet.Outputs[(int)NetworkOutputNames.DetectionRadius]));
            bool       CanAim           = myNet.Outputs[(int)NetworkOutputNames.CanAim] > 0.5f;
            float      Accuracy         = Mathf.Lerp(MinAccuracy, MaxAccuracy, myNet.Outputs[(int)NetworkOutputNames.Accuracy]);
            int        numGoals         = Mathf.RoundToInt(Mathf.Lerp(1, 4, myNet.Outputs[(int)NetworkOutputNames.Goals]));
            BaseWeapon WeaponForAI      = Weapons[Mathf.RoundToInt(Mathf.Lerp(0, Weapons.Count - 1, myNet.Outputs[(int)NetworkOutputNames.Weapon]))];
            float      MaxHealth        = Mathf.Lerp(50, 200, myNet.Outputs[(int)NetworkOutputNames.MaxHealth]);

            for (int i = 0; i < SpawnedAI.Count; ++i)
            {
                if (SpawnedAI[i] != null)
                {
                    SpawnedAI[i].DetectionRadius = DetectionRadius;
                    SpawnedAI[i].CanAimWeapon    = CanAim;
                    SpawnedAI[i].LookAccuracy    = Accuracy;
                    SpawnedAI[i].AddWeapon(WeaponForAI);
                    SpawnedAI[i].myDetectionObj.GetComponent <SphereCollider>().radius = DetectionRadius;

                    Health AIHealth = SpawnedAI[i].GetComponent <Health>();
                    AIHealth.MaxHealth = MaxHealth;
                    AIHealth.SetHealth(MaxHealth);

                    GoapAgent tempAgent = SpawnedAI[i].GetComponent <GoapAgent>();
                    AddGoals(ref tempAgent, numGoals);
                }
                else
                {
                    SpawnedAI.RemoveAt(i);
                    --i;
                }
            }
        }
    }
示例#6
0
 void Start()
 {
     _netController = GetComponent <NeuralNetController> ();
 }
示例#7
0
 void Start()
 {
     _netController = GetComponent<NeuralNetController> ();
 }
 void OnDestroy()
 {
     staticRef = null;
 }
 void Awake()
 {
     NewGenerationDuration();
     enemies   = new ControlCharacterML [numberOfEnemies];
     staticRef = this;
 }