Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:10:49+00:00 2026-06-14T17:10:49+00:00

I am trying to implement GBFS and A* with a grid (2D array). I

  • 0

I am trying to implement GBFS and A* with a grid (2D array). I think before we go any further…do both of the algorithms remember previous locations and if so, does this therefore mean that it will jump to that location if the heuristics are better i.e. would it jump to a node of a sibling’s child if the sibling’s children has better heuristics than the current node’s children? Better explanation would be for example, if I had a 8×8 grid and I was on coordinates 7,7, and I check the cells next to it but in the PriorityQueue, we have a coordinate 3,5 which has better heuristics than the cells next to 7,7…would we jump to 3,5?

if the answer is yes, then my problem is how would I create the correct path from the returned nodes that have been removed from the PriorityQueue given that we can jump from one location to another? I.e. how do we trim down the nodes to create the actual path?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:10:50+00:00Added an answer on June 14, 2026 at 5:10 pm

    Do both of the algorithms remember previous locations and if so, does this therefore mean that it will jump to that location if the heuristics are better i.e. would it jump to a node of a sibling’s child if the sibling’s children has better heuristics than the current node’s children?

    Yes to both.

    When you insert nodes into the priority queue you should keep track of their “parent” node, the node that preceded them. For example, if you’re at 7,7 and then add 8,7 to the queue you should set 8,7’s parent to 7,7.

    This way you can backtrack from any node back to the start node by following the chain of parents.

    If I had a 8×8 grid and I was on coordinates 7,7, and I check the cells next to it but in the PriorityQueue, we have a coordinate 3,5 which has better heuristics than the cells next to 7,7…would we jump to 3,5?

    Yes. Considering 3,5 after 7,7 doesn’t mean the player is “jumping” to 3,5. It means he’s now considering an alternate path since the path that goes through 3,5 seems more promising than the one through 7,7, at least momentarily.

    How would I create the correct path from the returned nodes that have been removed from the PriorityQueue?

    Eventually you will reach the goal node. Let’s say the goal node is 6,6 and you got there from 6,5. How do you reconstruct the path that got you there?

    • Look at 6,5’s parent.
    • Look at 6,5’s parent’s parent.
    • Look at 6,5’s parent’s parent’s parent.
    • etc.

    This will eventually get you back to the start node, and that is your path (in reverse).

    GBFS parents

    Take this example image based on your previous question. Each arrow represents one of the parent pointers you’d have. I changed colors each time the search “jumped” from one path to another. Notice how you can start from any of the nodes visited during the search and follow the arrows back to the start node.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying implement server code of Server-Sent Events in a generic way that any
I'm trying implement A* Start path finding in my games(which are written with JavaScript,
I am trying implement a most recent widget into my tumblr post. So far,
Trying to implement LoaderManager + CursorLoader. In onFinish method adapter should swap its cursor
Trying to implement google C2DM service. registrationIntent.putExtra(app, PendingIntent.getBroadcast(context,0,new Intent(), 0)); registrationIntent.putExtra(sender,example@gmail.com); context.startService(registrationIntent); Almost every
Trying to implement a search similar to here .This searches properties based on city,locality,property
Trying to implement 3-layer (not: tier, I just want to separate my project logically,
Trying to implement a rating system of users and postings. What is the best
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
Im trying to implement a destructor for the objects of linked-list Iv created. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.