Generating random points with defined minimum and maximum distance

前端 未结 4 1686
我在风中等你
我在风中等你 2020-12-11 06:34

I need algorithm ideas for generating points in 2D space with defined minimum and maximum possible distances between points.

Bassicaly, i want to find a good way to

4条回答
  •  Happy的楠姐
    2020-12-11 06:37

    How many points are you talking about? If you have an upper limit to the number of points, you can generate (pre-compute) an array of points and store them in the array. Take that array and store them in a file.

    You'll have all the hard computational processing done before the map loads (so that way you can use any random point generating algorithm) and then you have a nice fast way to get your points.

    That way you can generate a ton of different maps and then randomly select one of the maps to generate your points.

    This only works if you have an upper limit and you can precomputer the points before the game loads

提交回复
热议问题