public int findNearestAndConnectablePositionInRoadmap(Roadmap roadmap,Map map)
 {
     float minLen = float.MaxValue;
     float len;
     int index = -1;
     for (int i = 0; i < roadmap.samplePositionList.Count; i++)
     {
         len = Vector2.Distance(this.leftUpCorner, roadmap.samplePositionList[i].leftUpCorner);
         if (len < minLen)
         {
             if (this.isConnectable(roadmap.samplePositionList[i],map))
             {
                 minLen = len;
                 index = i;
             }
         }
     }
     return index;
 }
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     obstacleTexture = Content.Load<Texture2D>("obstacleImage");
     Texture2D tempTexture = Content.Load<Texture2D>("ball");
     goalPositionImageTexture = Content.Load<Texture2D>("goalPositionImage");
     Position agent1StartPosition = new Position(new Vector2(10, 10), new Vector2(tempTexture.Width, tempTexture.Height));
     Position agent1FinishPosition = new Position(new Vector2(800, 500), new Vector2(tempTexture.Width, tempTexture.Height));
     agent1 = new Agent(this, tempTexture, "Agent1", Color.DarkBlue, agent1StartPosition, agent1FinishPosition);
     roadmap = new Roadmap(gameMap, agent1, sampleSize, depth);
 }