Beispiel #1
0
        private void ExecuteAction(KnownAction action)
        {
            float verticalForce   = 0f;
            float horizontalForce = 0f;

            switch (action)
            {
            case KnownAction.FlyForward:
                horizontalForce = 8;
                verticalForce   = 100;
                break;

            case KnownAction.FlyDown:
                verticalForce = -175;
                break;

            case KnownAction.FlyUp:
                verticalForce = 250;
                break;
            }


            this._rigidBody.AddForce(this.transform.right * horizontalForce);
            this._rigidBody.AddForce(this.transform.up * verticalForce * 0.1f);

            this._rigidBody.velocity = Vector3.ClampMagnitude(this._rigidBody.velocity, this.DNA.MaximumSpeed);
            this.DistanceTravelled   = this.transform.position.x - this._startPosition.x;
        }
Beispiel #2
0
        public void Mutate()
        {
            KnownSituation randomSituation = AllKnownSituations[Random.Range(0, AllKnownSituations.Count())];
            KnownAction    randomAction    = AllKnownActions[Random.Range(0, AllKnownActions.Count())];

            this.SituationMap[randomSituation] = randomAction;
        }
Beispiel #3
0
        void FixedUpdate()
        {
            if (!this._isAlive)
            {
                return;
            }

            KnownAction currentAction = this.DNA.SituationMap[this._currentSituation];

            this.ExecuteAction(currentAction);
        }
Beispiel #4
0
        public static DNA CreateRandomDna()
        {
            DNA randomDna = new DNA();

            randomDna.MaximumSpeed    = Random.Range(1, 6);
            randomDna.ViewingDistance = Random.Range(1, 8);
            foreach (KnownSituation situation in AllKnownSituations)
            {
                KnownAction randomAction = AllKnownActions[Random.Range(0, AllKnownActions.Count())];
                randomDna.SituationMap[situation] = randomAction;
            }

            return(randomDna);
        }