         
 
 }
-
+//resets in_path to false for all locations 
 void reset_path() {
   for(int i = 0; i <20; i++){
     for(int j = 0; j <20; j++){  

    delay(50);

    Serial.println(cm[i]);



  }
}
void update_grid(int x, int y, int target_x,int target_y){
  updateSonar();
  float sonarleft = cm[0];


  if(sonarleft <= 150 && sonarleft != 0){
    int unoccupied = sonarleft/25;
    
    for (int u = 0; u <= unoccupied; u++){
      grid[x + u][y].walkable = true;
    }

 // cout << "[""]" << "\n";

// updateSonar();
reset_path(); //first you reset path
reset_lists(); //then reset list
update_grid(0,0,18,0); //then update grid for obstacles 
 FindPath(0,0,18,0); // then find the path based on updated grid
      show_Grid(); //then show the vidualized grid

delay(5000);
}
