Esempio n. 1
0
 // Sets up the behaviors that this agent uses. Should be called by implementing classes
 public void initialize()
 {
     this.smellFollower    = new SmellFollower();
     this.wallAvoider      = new WallAvoider(MAIN_RAY_LENGTH, SIDE_RAY_LENGTH, transform, MAX_ACCEL);
     this.collisionAvoider = new CollisionAvoider(COLLISION_AVOIDANCE_RAD, transform, rigidBody, MAX_ACCEL);
     this.arriver          = new Arriver(ARRIVE_RADIUS, SLOW_RADIUS, MAX_SPEED, rigidBody);
     this.aligner          = new Aligner(ROTATE_ARRIVE_RAD, ROTATE_SLOW_RAD, MAX_ANGULAR_ACC, transform, rigidBody);
     this.fleer            = new Fleer(FLEE_TAG_RAD, transform, MAX_ACCEL);
     this.seeker           = new Seeker(MAX_ACCEL, transform);
     this.pursuer          = new Pursuer(MAX_ACCEL, rigidBody);
     this.wanderer         = new Wanderer(MAX_ACCEL, transform);
     this.mover            = new Mover(MAX_ACCEL, MAX_ANGULAR_ACC, MAX_SPEED, MAX_ROTATION, rigidBody);
 }
Esempio n. 2
0
        //public Vector2D Calculate()
        //{
        //    Vector2D force; // My force will be stored here
        //    Vector2D pos = _me.Pos; // Position of the agent

        //    // For each wall
        //    for (int j = 0; j < _me.Walls.Count(); j++)
        //    {
        //        var wall = _me.Walls[j];
        //        var x = (wall.Center.X + _me.Pos.X) / 2;
        //        var y = (wall.Center.Y + _me.Pos.Y) / 2;
        //        Vector2D distance = new Vector2D(x, y);

        //        // If the wall is visible, calculate the force to apply
        //        double dotProduct = distance * partsList[j]->normal();
        //        if (dotProduct < 0)
        //        {
        //            force += partsList[j]->normal() / (distance.length() * distance.length() + 1);
        //        }
        //    }

        //    // Returned the calculated force
        //    return force;
        //}

        public IWall GetClosestWall(IWallAvoider ME)
        {
            IWall mostThreatening = null;

            for (int i = 0; i < ME.Walls.Count(); i++)
            {
                IWall wall      = ME.Walls[i];
                bool  collision = findSensorCollision(wall);
                if (collision && (mostThreatening == null || VectorMath.DistanceBetweenPositions(ME.Pos, wall.Center) < VectorMath.DistanceBetweenPositions(ME.Pos, mostThreatening.Center)))
                {
                    mostThreatening = wall;
                }
            }
            return(mostThreatening);
        }
Esempio n. 3
0
 public WallAvoidance(IWallAvoider me, double maxSeeAhead = 15, double maxAvoidForce = 35)
 {
     _me           = me;
     MaxSeeAhead   = maxSeeAhead;
     MaxAvoidForce = maxAvoidForce;
 }