[Algorithmic practice in the maze] summary of a data structure and algorithm practice work

Source: Internet
Author: User

Recently heard that the data structure and algorithm practice teacher again out of the same topic as the previous year, can not help but think of the last time I finished homework when the point drops, regret at that time did not write the habit of blogging, some of the previous experience this year the past also gradually forgotten, suddenly have a summary of the idea, hoping to have a new harvest it.

Because at that time also did not pay attention to save, the software completed the process of some documents have been lost, fortunately, WinForm version of the source code is still in, Unity3d version of the program also survived, although due to time tension only completed the approximate framework, but the aesthetic degree is far from WinForm can compare, first on a few software diagram bar:

Generation algorithm

Software realizes the premium Manaus algorithm, recursive backtracking algorithm, recursive segmentation algorithm and depth traversal graph algorithm four kinds of algorithms to complete the maze generation, the first two algorithms generated by the maze is essentially a two-dimensional matrix network form of the spanning tree, which means that there is no loop, At the same time from the bottom left to every point in the maze and there is only one path, recursive segmentation method, although not a spanning tree algorithm but also belongs to the maze generation algorithm without loops, the depth traversal graph algorithm is derived from the knowledge on-line paper, which is the depth of the graph traversal algorithm, the resulting maze more random, more than one path, But I have to say that appearance is quite poor indeed.

Premium Manaus algorithm Maze (Prim)

Recursive segmentation algorithm ( Recursive Division)

Recursive backtracking (Recursive backtracker)

Depth traversal graph (deep traversal graph)

pathfinding algorithm

      As for the pathfinding algorithm, the software realizes depth-first traversal, breadth-first traversal, and A-star three kinds of algorithms, the first two kinds of self-needless to say, A-star algorithm is a heuristic search algorithm, Moving will assess the expected cost of walking to the surrounding eight direction, the real-time selection of a smaller cost of movement direction, but because the maze is a square maze and start and end fixed to the top left and right, so in this project, the A-star algorithm does not play its due wit, efficiency and breadth first basically the same. The latter two algorithms can find the shortest path, and the depth first will not show. Green is the correct route in the figure, and blue is the route that passes during the pathfinding process. (PS: Set for depth breadth four-direction movement, A-star eight-direction movement)

depth-first traversal (DFS)

 

 

  a-star

  because of the particularity of the Labyrinth entrance exit location in the instance, the breadth first must go completely in the path-finding process, and it seems somewhat less witty

This article is a review, the following algorithm will be divided into a separate chapter.

[Algorithmic practice in the maze] summary of a data structure and algorithm practice work

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.