Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. def genRandomMap(self):
  2. # choose no. of obstacles, their centers and sizes
  3. numObst = np.random.randint(10,15)
  4. centers = np.random.random(size=[numObst,2])
  5. centers[:,0] = centers[:,0]*0.6*self.width + 0.2
  6. centers[:,1] = centers[:,1]*0.6*self.height + 0.2
  7. sizes = 1+np.random.random(size=[numObst,2])*0.5
  8.  
  9. # choose the number of sides
  10. numSides = np.random.randint(3,10, size = numObst)
  11.  
  12. self.polyList = []
  13. for i in range(numObst):
  14. # randomly sample points around centers
  15. numRandPts = 2*numSides[i]
  16. # print(numRandPts)
  17. pts = centers[i].reshape((1,2)).repeat(numRandPts, axis = 0) + np.random.random(size = [numRandPts,2])*sizes[i]
  18. # print(centers[i].reshape((1,2)).repeat(numRandPts, axis = 0).shape, np.random.random(size = [numRandPts,2].shape))
  19. # print(centers[i].reshape((1,2)).repeat(2, axis = 0)) #np.random.random(size = [numRandPts,2]).shape)
  20. polygon = convexHull(pts)
  21. # print(polygon)
  22. self.polyList.append(polygon)
  23.  
  24. # self.start = np.random.random(size=2)
  25. # self.start[0]*= self.width
  26. # self.start[1]*= self.height
  27. # self.goal = np.random.random(size=2)
  28. # self.goal[0]*= self.width
  29. # self.goal[1]*= self.height
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement