Beispiel #1
0
        public override void update()
        {
            if (!isLive)
            {
                return;
            }

            Obsticle closest = closestObst();
            ///for some reason the training is extremely fast WITHOUT input normalization
            float dx = (float)(closest.XRight() - X()) / Global.winWidth,
                  dy = (float)(closest.hatchYCenter() - YCenter()) / Global.winHeight,
                  vy = this.vy / Global.winHeight;

            ///feed values to the network
            float[] input = new float[] { dx, dy, vy };
            ///procces output and play accourdingly
            double prob = brain.GetOutput(input)[0];

            if (prob >= 0.5)
            {
                jump();
            }
            ///update bird
            movmentManager();
            CheckCollitions();
        }
Beispiel #2
0
        public override void update()
        {
            Obsticle closest = closestObst();
            double   dx      = (float)(closest.XRight() - X()) / Global.winWidth,
                     dy      = (float)(closest.hatchYCenter() - YCenter()) / Global.winHeight,
                     vy      = this.vy / Global.winHeight;
            ///feed values to the network
            Vector <double> input = Vector <double> .Build.DenseOfArray(new double[] { dx, dy, vy });

            ///procces output and play accourdingly
            double prob = brain.feedNet(input)[0];

            if (prob >= 0.5)
            {
                jump();
            }
            ///update bird
            movmentManager();
            CheckCollitions();
        }