Algorithm to find two points furthest away from each other

前端 未结 9 1335
闹比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:13

    Finished a python mockup of the dijkstra solution to the problem. Code got a bit long so I posted it somewhere else: http://refactormycode.com/codes/717-dijkstra-to-find-two-points-furthest-away-from-each-other

    In the size I set, it takes about 1.5 seconds to run the algorithm for one node. Running it for every node takes a few minutes.

    Dont seem to work though, it always displays the topleft and bottomright corner as the longest path; 58 tiles. Which of course is true, when you dont have obstacles. But even adding a couple of randomly placed ones, the program still finds that one the longest. Maybe its still true, hard to test without more advanced shapes.

    But maybe it can at least show my ambition.

提交回复
热议问题