private Position getFreePosition()
        {
            int displayWidth = agent.game.graphics.PreferredBackBufferWidth;
            int displayHeight = agent.game.graphics.PreferredBackBufferHeight;

            bool continueSearch = true;
            Position position;
            do
            {
                position = new Position(new Vector2(rand.Next(0, displayWidth - agent.texture.Width), rand.Next(0, displayHeight - agent.texture.Height)), new Vector2(agent.texture.Width, agent.texture.Height));
                continueSearch = false;
                foreach (Obstacle obs in map.obstacleList)
                {
                    if (position.Intersect(obs.position))
                    {
                        continueSearch = true;
                        break;
                    }
                }
            } while (continueSearch);
            return position;
        }
 /// <summary>
 /// Seçilmiş harita içerisinde herhangi bu pozisyona bir serbest bir yolun olup olmadığını hesaplar.
 /// </summary>
 /// <param name="position"></param>
 /// <param name="map"></param>
 /// <returns></returns>
 public bool isConnectable(Position position, Map map)
 {
     Position virtualPosition = new Position(this.leftUpCorner, this.size);
     Vector2 direction;
     bool XisSame = false;
     bool YisSame = false;
     while (true)
     {
         direction = position.leftUpCorner - virtualPosition.leftUpCorner;  // Yön belirlenir.
         direction.Normalize();
         virtualPosition.leftUpCorner += direction;
         if (float.IsNaN(virtualPosition.leftUpCorner.X) || float.IsNaN(virtualPosition.leftUpCorner.Y))
             return false;
         foreach (Obstacle obs in map.obstacleList)
         {
             if (virtualPosition.Intersect(obs.position))
                 return false;
         }
         if ((Math.Abs(virtualPosition.leftUpCorner.X - position.leftUpCorner.X) <= (Math.Abs(direction.X * 2))) && !XisSame )
         {
             XisSame = true;
             virtualPosition.leftUpCorner.X = position.leftUpCorner.X;
         }
         if ((Math.Abs(virtualPosition.leftUpCorner.Y - position.leftUpCorner.Y) <= (Math.Abs(direction.Y * 2))) && !YisSame )
         {
             YisSame = true;
             virtualPosition.leftUpCorner.Y = position.leftUpCorner.Y;
         }
         if (XisSame && YisSame)
             return true;
     }
 }