Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


A* with Binary Heap error


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 Nemean Charisma   Members   -  Reputation: 122

Like
0Likes
Like

Posted 21 March 2012 - 06:01 AM

Hi,

I have just started learning A* and I did successfully to implement with std::vector in C++. However, when I am integrating my Binary Heap implementation, I have problems with POINTER etc and I have spent much time to debug but still could not get a solution of it. May I ask for a little help?

PROBLEM: Whenever I want to access the parent pointer it will give me run time error. The same algorithm (A*) runs smoothly when I am using std::vector.

Inside my CellNode.h

void Print(){
  cout << "Cell Node id : " <<  m_id << " ("<<m_xcoord << " , " << m_zcoord << ")" <<" F = "<< getF()
   << " G = " << getG() << " H = " << getH();
  if ( parent != 0){
   cout << "Cell Node Parent id " << parent->m_id << endl;
  }
  else{
   cout << endl;
  }
}
It enters the if condition but it doesn't have any parent reference. I am pretty much confused with this.

In the implementation I am using Visual Studio 2010 and OpenGL as the graphics rendering. Any kind of help is much appreciated..

Thanks. Posted Image

Attached Files



Sponsor:

#2 ApochPiQ   Moderators   -  Reputation: 17439

Like
0Likes
Like

Posted 21 March 2012 - 11:08 AM

What's the actual error you get at runtime? The exact text is important.

I suspect you're calling Print() on a null pointer, but that's just an uneducated guess ;-)

#3 Nemean Charisma   Members   -  Reputation: 122

Like
0Likes
Like

Posted 21 March 2012 - 12:32 PM

Hi,

You were right, it does something to do with NULL pointer. Have you tried to create VS 2010 project and copy my source codes? You will see the error looks something like the image attached.Posted Image

#4 ApochPiQ   Moderators   -  Reputation: 17439

Like
0Likes
Like

Posted 21 March 2012 - 12:46 PM

You should be running this under the debugger (just press F5) and the debugger will give you the actual error that occurs (e.g. Access Violation reading address 0x00000004 or something similar). Can you paste that text here?

#5 Nemean Charisma   Members   -  Reputation: 122

Like
0Likes
Like

Posted 22 March 2012 - 02:43 AM

Posted Image

That's what I got the error when debugging. Anyway that I can understand this message?

#6 ApochPiQ   Moderators   -  Reputation: 17439

Like
0Likes
Like

Posted 22 March 2012 - 10:54 AM

You're accessing a bogus variable, possibly by returning a pointer to a stack-allocated object or something similar.

Check out this article for some tips on reading error messages.

#7 SiCrane   Moderators   -  Reputation: 10171

Like
0Likes
Like

Posted 22 March 2012 - 11:00 AM

In particular MSVC uses 0xCCCCCCCC for uninitialized stack variables.

#8 Nemean Charisma   Members   -  Reputation: 122

Like
0Likes
Like

Posted 22 March 2012 - 10:25 PM

Phew...that's a nasty debugging skill I should have. I wil try to revise my Microprocessor Programming concept and theory for this matter. Let me get back to you once I got 'something' from it. Thanks. Posted Image

#9 Nemean Charisma   Members   -  Reputation: 122

Like
0Likes
Like

Posted 23 March 2012 - 12:32 AM

Hi,

I am facing a lot of problem when reading assembly language. This is the print screen of debugging with Assembly language. It got an error on this particular line. Posted Image

#10 SiCrane   Moderators   -  Reputation: 10171

Like
0Likes
Like

Posted 23 March 2012 - 09:41 AM

The only pointer dereference that seems to be present is for parent. If parent is a member variable then there may be an implicit dereference of this. So one of the possible situations is that you're calling a member function on an uninitialized pointer to your class. Another situation is that you're calling a member function on a stack object that hasn't initialized the parent member variable for some reason.

#11 Nemean Charisma   Members   -  Reputation: 122

Like
0Likes
Like

Posted 24 March 2012 - 08:07 PM

The parent object pointers have been initialized in a particular method. Inside my AStarHeap project you can inspect the codes and debug.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS