Pathfinding on large map

前端 未结 7 1220
我在风中等你
我在风中等你 2021-02-02 12:34

I\'m creating a game with a 10,000 by 10,000 map.
I would like for a user to be able to set a location and have the computer instantly find the best path.
However, since

7条回答
  •  长发绾君心
    2021-02-02 12:52

    A high level concept might be to find the points of the start and end - say point (0,0) and point (10000, 10000) - and make a preliminary guess for a path going from beginning to end (in this case it would run diagonally the whole way up and to the right) Then start checking to see if it can successfully get there (if there are obstacles on that path or not). If there are then programmatically choose similar paths, or alternately find where the path fails and start there and try to iterate until it works, it might not be 100% the fastest but you will get a lot better results than finding every single possible way, then deducing the shortest path from that.

    Implementation

    • Method to find initial shortest path
    • Run to see if it works
      • If it fails then either try similar path or start from failure

提交回复
热议问题