Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def genRandomMap(self):
- # choose no. of obstacles, their centers and sizes
- numObst = np.random.randint(10,15)
- centers = np.random.random(size=[numObst,2])
- centers[:,0] = centers[:,0]*0.6*self.width + 0.2
- centers[:,1] = centers[:,1]*0.6*self.height + 0.2
- sizes = 1+np.random.random(size=[numObst,2])*0.5
- # choose the number of sides
- numSides = np.random.randint(3,10, size = numObst)
- self.polyList = []
- for i in range(numObst):
- # randomly sample points around centers
- numRandPts = 2*numSides[i]
- # print(numRandPts)
- pts = centers[i].reshape((1,2)).repeat(numRandPts, axis = 0) + np.random.random(size = [numRandPts,2])*sizes[i]
- # print(centers[i].reshape((1,2)).repeat(numRandPts, axis = 0).shape, np.random.random(size = [numRandPts,2].shape))
- # print(centers[i].reshape((1,2)).repeat(2, axis = 0)) #np.random.random(size = [numRandPts,2]).shape)
- polygon = convexHull(pts)
- # print(polygon)
- self.polyList.append(polygon)
- # self.start = np.random.random(size=2)
- # self.start[0]*= self.width
- # self.start[1]*= self.height
- # self.goal = np.random.random(size=2)
- # self.goal[0]*= self.width
- # self.goal[1]*= self.height
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement