Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Path Finding
Forum Updated to NodeBB v4.3 + New Features

Path Finding

Scheduled Pinned Locked Moved Game Development
2 Posts 2 Posters 3.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cazador7907
    wrote on 10 Mar 2011, 12:50 last edited by
    #1

    I am not sure where to post this question as it concerns an algorithm and not an aspect of C++ or Qt.

    Anyway, I am working on the development of a path finding routine. I put the pseudo code below and wanted to ask for people opinions and thoughts. The routine will search for a path across a sparsely populated Graph Object. The F-Cost is calculated based on the Heuristic of a node, the length of the edge connecting two nodes and efficiency of the edge.

    The MasterList is a QMap Object
    The OpenList is a Binary Heap
    The Path object is a QVector

    @
    Path finding pseudo code

    1. Initialize the two heaps: Open and Master.
    2. Initialize the return Path vector object.
    3. Is the starting node equal to the ending node?
      a. Add the end node to the return Path.
      b. Exit.
    4. Create a new Path element from the starting node. F-Cost will be 0.0.
    5. Add the Path element to the Master and Open heaps.
    6. Examine each edge connected to the starting node.
      a. If the edge is owned, skip it and move to the next edge.
      b. If the edge is un-owned
      i. Create a new path node out of the destination node
      ii. Calculate the F-Cost for the destination node.
      iii. Set its parent property to the current node.
      iv. If the destination node equals the end point
      1. Add the destination node to the Path vector
      2. Exit
      v. If the destination node is not the end point
      1. Add the destination node to the Master and Open Heaps.
    7. Find the current node in the Master heap and mark it closed.
      a. Set its closed property to true.
    8. Pop the path node having the lowest F-Cost off of the Open heap and make it the current node.
    9. Repeat the above process starting at #6.

    @

    Laurence -

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on 27 Mar 2011, 22:48 last edited by
      #2

      Hi,

      In my opinion it is always easier to explain such kind of algorithm with a block diagram (espesially if it is executed by a single thread) :) You can also get inspiration for optimal solution from existing solutions for path finding algorithms such as the different implementations of the traveling salesman problem ;)

      Best regards,
      Leon

      http://anavi.org/

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved