How can I find the shortest path between 100 moving targets? (Live demo included.)

后端 未结 4 545
情话喂你
情话喂你 2021-01-29 21:42

Background

This picture illustrates the problem: \"square_grid_with_arrows_giving_directions\"

I can cont

4条回答
  •  情歌与酒
    2021-01-29 22:11

    I think another approch would be:

    • calculate the path of the targets - predictive.
    • than use Voronoi diagrams

    Quote wikipedia:

    In mathematics, a Voronoi diagram is a way of dividing space into a number of regions. A set of points (called seeds, sites, or generators) is specified beforehand and for each seed there will be a corresponding region consisting of all points closer to that seed than to any other.

    So, you choose a target, follow it's path for some steps and set a seed point there. Do this with all other targets as well and you get a voroni diagram. Depending in which area you are, you move to the seedpoint of it. Viola, you got the first fish. Now repeat this step until you cought them all.

提交回复
热议问题