Advertisement

Strange Errors

Started by July 08, 2001 02:56 AM
1 comment, last by Lorg 23 years, 7 months ago
Hi I was programming a somewhat simple game with my friend (on bc5, using directx), when a strange error beset us. We have 2 ''major'' classes in the game, the CGame (game logic) class, and the CEngine (game graphics) class. in the CGame class, we also hold as member variables, a couple of vars (of the same type) that act as the game AI of the same class (CGameAI). One of CGameAI ''s functions is: void Learn(double *input,double *desired_output); where input and desired_output are actually arrays. (The user of CGameAI allocates the memory, and takes care of deletes) Now, the CGameAI class is a fully debugged class, that I already worked with a couple of times, and 1. it worked 2. it had no bugs (!) (at least, not apparent ones The problem is, that under this implementation, it has the following bug: CGame holds as member variables a couple of double arrays, to send to CGameAI::Learn. These arrays are filled by some function in the game loop. But when in Learn, the desired_output array is accessed, the game crashes for no apparent reason. My friend suggested that its something to do with the stack, but I am not quite sure of what that means . So both of us are quite puzzled, befuddled, and whatnot. But mostly annoyed- this thing is the ''final barrier'' before the game works. If any of you have any applicable advice, please reply, it will be greatly appreciated. Lorg.
I would suggest posting you code somewhere like a free webpage and asking people to sift through it if they dont mind. Definately need more input as there''s a million and one possiblities to what could be causing it to crash. Good Luck.
Advertisement
It''s probably not stack--you''re just passing pointers, so regardless of the size of the arrays only two pointers will be on the stack.

The first obvious thing to check for is if your array bounds are being overrun. Double-check that you have allocated memory to the pointers you''ve passed-in, and that it''s enough memory.

Otherwise, we need a little more direction before we can help--what specifically do you mean by "it crashes"? Are you running in debug mode? Can you track down at which line it crashes? Please post some code.

This topic is closed to new replies.

Advertisement