I’ve got a problem I’m not too sure how to solve. I have a 2d space with several points in it. I also have a current point, which is one of the points in the space. I want to randomly select one of the other point, with a higher probability for selection being given to points closer to my current point. I’m working in Java. Any tips would be much appreciated.
Share
Assign a “weight” to each point by for instance computing
1 / distanceFromCurrent.Select a point based on these weights.
Solution for the latter part can for instance be found in some of the following answers:
Another option would be to use
java.util.Random.nextGaussian. Adjust the resulting double so that it represents a reasonable radius, and select the neighboring point closest to this radius.