Algorithm to find two points furthest away from each other

前端 未结 9 1363
闹比i
闹比i 2020-12-13 06:23

Im looking for an algorithm to be used in a racing game Im making. The map/level/track is randomly generated so I need to find two locations, start and goal, that makes use

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 07:06

    It sounds like what you want is the end points separated by the graph diameter. A fairly good and easy to compute approximation is to pick a random point, find the farthest point from that, and then find the farthest point from there. These last two points should be close to maximally separated.

    For a rectangular maze, this means that two flood fills should get you a pretty good pair of starting and ending points.

提交回复
热议问题