Esempio n. 1
0
        public bool GetClosestSensor(Food food, ProximitySensor sensorA, ProximitySensor sensorB)
        {
            if (Math.Abs(food.FoodRectangle.X - sensorA.rotatedPosition.X) + Math.Abs(food.FoodRectangle.Y - sensorA.rotatedPosition.Y) < Math.Abs(food.FoodRectangle.X - sensorB.rotatedPosition.X) + Math.Abs(food.FoodRectangle.Y - sensorB.rotatedPosition.Y))
            {
                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        public Fish(NeuralNetwork newBrain)
        {
            texture = content.Load <Texture2D>("Sprites/fish.png");
            brain   = newBrain;

            position  = new Vector2(random.Next((Game1.screenWidth - Game1.theoreticalScreenWidth) / 2, ((Game1.screenWidth - Game1.theoreticalScreenWidth) / 2) + Game1.theoreticalScreenWidth - texture.Width), random.Next((Game1.screenHeight - Game1.theoreticalScreenHeight) / 2, ((Game1.screenHeight - Game1.theoreticalScreenHeight) / 2) + Game1.theoreticalScreenHeight - texture.Height));
            rectangle = new Rectangle((int)(position.X), (int)(position.Y), texture.Width, texture.Height);
            origin    = new Vector2(texture.Width / 2, texture.Height / 2);

            collisionCircle = new CollisionCircle((int)(position.X - origin.X), (int)(position.Y - origin.Y));

            rotation           = 90;
            proximitySensor[0] = new ProximitySensor((int)(position.X), (int)(position.Y));
            proximitySensor[1] = new ProximitySensor((int)(position.X), (int)(position.Y));
            proximitySensor[2] = new ProximitySensor((int)(position.X), (int)(position.Y));
        }
Esempio n. 3
0
        public bool GetClosestSensor(Food food, ProximitySensor sensorA, ProximitySensor sensorB)
        {
            if (Math.Abs(food.FoodRectangle.X - sensorA.rotatedPosition.X) + Math.Abs(food.FoodRectangle.Y - sensorA.rotatedPosition.Y) < Math.Abs(food.FoodRectangle.X - sensorB.rotatedPosition.X) + Math.Abs(food.FoodRectangle.Y - sensorB.rotatedPosition.Y))
                return true;

            return false;
        }
Esempio n. 4
0
        public Fish(NeuralNetwork newBrain, CollisionCircle newCollisionCircle)
        {
            texture = content.Load<Texture2D>("Sprites/fish.png");
            brain = newBrain;

            position = new Vector2(random.Next((Game1.screenWidth - Game1.theoreticalScreenWidth) / 2, ((Game1.screenWidth - Game1.theoreticalScreenWidth) / 2) + Game1.theoreticalScreenWidth - texture.Width), random.Next((Game1.screenHeight - Game1.theoreticalScreenHeight) / 2, ((Game1.screenHeight - Game1.theoreticalScreenHeight) / 2) + Game1.theoreticalScreenHeight - texture.Height));
            rectangle = new Rectangle((int)(position.X), (int)(position.Y), texture.Width, texture.Height);
            origin = new Vector2(texture.Width / 2, texture.Height / 2);

            collisionCircle = newCollisionCircle;

            rotation = 90;
            proximitySensor[0] = new ProximitySensor((int)(position.X), (int)(position.Y));
            proximitySensor[1] = new ProximitySensor((int)(position.X), (int)(position.Y));
            proximitySensor[2] = new ProximitySensor((int)(position.X), (int)(position.Y));
        }