Exemplo n.º 1
0
        internal Missle(Point centerPoint, double missleAngle, int id, GenericDrawingPanel gamePanel, int frameRate)
        {
            this.GamePanel  = gamePanel;
            this.FrameRate  = frameRate;
            this.SetIDTag   = id;
            this.IsAlive    = true;
            this.IsKillable = true;

            this.VeloXTrun = 0;
            this.VeloYTrun = 0;

            this.FramesRemaining = this.FrameRate * this.LifeSpan;

            double radAngle = Math.PI / (double)180 * (missleAngle + 90);

            this.VeloX = this.TotalVelocity * Math.Cos(radAngle);
            this.VeloY = this.TotalVelocity * Math.Sin(radAngle);

            this.CenterPoint = PointAdjuster.adjustPointAcc(
                centerPoint,
                (int)this.VeloX * 2,
                (int)this.VeloY * 2,
                this.GamePanel.GetPanelWidth,
                this.GamePanel.GetPanelHeight);
        }
Exemplo n.º 2
0
 internal Asteroid(GenericDrawingPanel gamePanel, int frameRate)
 {
     this.GamePanel  = gamePanel;
     this.FrameRate  = frameRate;
     this.IsKillable = true;
     regenerate();
 }
Exemplo n.º 3
0
        /// <summary>
        /// User controlled ship
        /// </summary>
        /// <param name="flyingObjects">Stores all of the detectable objects</param>
        /// <param name="frameRate">The number of frames which equal a second</param>
        /// <param name="totalMissles">The total number of missles the space ship will be allowed to fire</param>
        internal SpaceShip(GenericDrawingPanel gamePanel, List <AbstractObject> flyingObjects, int frameRate, int totalMissles)
        {
            this.RestPoint = new Point(
                this.GamePanel.GetPanelWidth / 2 + this.GamePanel.GetPanelLocX,
                this.GamePanel.GetPanelHeight / 2 - this.GamePanel.GetPanelLocY);

            spaceShipInit(ref gamePanel, false, ref flyingObjects, frameRate, totalMissles);
        }
Exemplo n.º 4
0
        /// <summary>
        /// neural net controlled ship
        /// </summary>
        /// <param name="flyingObjects">Stores all of the detectable objects</param>
        /// <param name="frameRate">The number of frames which equal a second</param>
        /// <param name="totalMissles">The total number of missles the space ship will be allowed to fire</param>
        /// <param name="numEyes">The number of eyes the ship will used to detect other flying objects</param>
        /// <param name="numLayers">The number of hidden layers in the feedforward network</param>
        /// <param name="totalNets">The total number of neural nets the space ship will user in its genetic algorithm</param>

        internal SpaceShip(
            GenericDrawingPanel gamePanel,
            List <AbstractObject> flyingObjects,
            int frameRate,
            int totalMissles,
            Point restPoint,
            int numEyes   = 8,
            int numLayers = 0,
            int totalNets = 40
            )
        {
            this.RestPoint = new Point(restPoint.X, restPoint.Y);
            spaceShipInit(ref gamePanel, false, ref flyingObjects, frameRate, totalMissles, numEyes, numLayers, totalNets);
        }
Exemplo n.º 5
0
        /// <summary>
        /// neural net controlled ship
        /// </summary>
        /// <param name="flyingObjects">Stores all of the detectable objects</param>
        /// <param name="frameRate">The number of frames which equal a second</param>
        /// <param name="totalMissles">The total number of missles the space ship will be allowed to fire</param>
        /// <param name="numEyes">The number of eyes the ship will used to detect other flying objects</param>
        /// <param name="numLayers">The number of hidden layers in the feedforward network</param>
        /// <param name="totalNets">The total number of neural nets the space ship will user in its genetic algorithm</param>

        internal SpaceShip(
            GenericDrawingPanel gamePanel,
            List <AbstractObject> flyingObjects,
            int frameRate,
            int totalMissles,
            int numEyes   = 8,
            int numLayers = 0,
            int totalNets = 40
            )
        {
            this.RestPoint = new Point(
                gamePanel.GetPanelWidth / 2 + gamePanel.GetPanelLocX,
                gamePanel.GetPanelHeight / 2 - gamePanel.GetPanelLocY);
            spaceShipInit(ref gamePanel, false, ref flyingObjects, frameRate, totalMissles, numEyes, numLayers, totalNets);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Constructor helper function
        /// </summary>
        /// <param name="isUser">Is this a user controlled ship?</param>
        /// <param name="flyingObjects">Stores all of the detectable objects</param>
        /// <param name="frameRate">The number of frames which equal a second</param>
        /// <param name="totalMissles">The total number of missles the space ship will be allowed to fire</param>
        /// <param name="numEyes">The number of eyes the ship will used to detect other flying objects</param>
        /// <param name="numLayers">The number of hidden layers in the feedforward network</param>
        /// <param name="totalNets">The total number of neural nets the space ship will user in its genetic algorithm</param>

        private void spaceShipInit(ref GenericDrawingPanel gamePanel, bool isUser, ref List <AbstractObject> flyingObjects, int frameRate, int totalMissles, int numEyes = -1, int numLayers = -1, int totalNets = -1)
        {
            this.IsUser       = isUser;
            this.TotalMissles = totalMissles;
            this.FrameRate    = frameRate;

            this.giveIDTag();

            this.GamePanel = gamePanel;


            this.NumEyes       = numEyes;
            this.FlyingObjects = flyingObjects;

            this.EyeInputArray     = new Point[this.NumEyes];
            this.EyeOffcenterArray = new Point[this.NumEyes];
            this.EyeFractionArray  = new double[this.NumEyes];
            restShip();
            double xPoint;
            double yPoint;

            for (int i = 0; i < this.NumEyes; i++)
            {
                double radAngle = (double)(((double)i * 2 * Math.PI) / (this.NumEyes)) + (double)(Math.PI / 2);
                xPoint = this.EyeRadius * Math.Cos(radAngle);
                yPoint = this.EyeRadius * Math.Sin(radAngle);

                this.EyeOffcenterArray[i] = new Point((int)xPoint, (int)yPoint);
            }
            updateEyes();

            if (!this.IsUser)
            {
                //all the eye distances will be inputs
                //Forward, left, right, shoot output
                this.allNets = new GeneticNets(this.NumEyes + 5, 4, numLayers, totalNets);
            }
        }