Heap overflow

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Heap overflow

Bhathiya Jayasekara
Hi,
I tried to develop WUMPUS game. But I get the 'heap overflow' exception often. I think it's due to use of recursion. Can someone help me to overcome this issue?

Here is the code.

search( [p(F,[State|Path],PrevActions)|Open], GoalState, Solution) :-
   State \== GoalState & //.print("  ** ",State," ",PrevActions) & 
   .findall(
        p(NewF,[NewState,State|Path],[Action|PrevActions]), // new paths 
        ( next_state(State,Action,NewState) & 
          not .member(NewState, [State|Path]) & 
          NewF = search.h(NewState,GoalState) + .length(PrevActions) + 1
        ), 
        Sucs) &
   .concat(Open,Sucs,LT) & 
   .sort(LT,NewOpen) &  // sort by F (H+G), so A*
   //.print("open nodes #",.length(NewOpen)) & //.print(" new open = ",NewOpen) & 
   search( NewOpen, GoalState, Solution).



------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Heap overflow

Jomi Hubner
This code is a not so efficient implementation of A* search algorithm.... You likely can solve the problem implementing it in Java (see the gold miners example).

HTH,

Jomi

On 24/01/2011, at 09:09, Bhathiya Jayasekara wrote:

Hi,
I tried to develop WUMPUS game. But I get the 'heap overflow' exception often. I think it's due to use of recursion. Can someone help me to overcome this issue?

Here is the code.

search( [p(F,[State|Path],PrevActions)|Open], GoalState, Solution) :-
   State \== GoalState & //.print("  ** ",State," ",PrevActions) & 
   .findall(
        p(NewF,[NewState,State|Path],[Action|PrevActions]), // new paths 
        ( next_state(State,Action,NewState) & 
          not .member(NewState, [State|Path]) & 
          NewF = search.h(NewState,GoalState) + .length(PrevActions) + 1
        ), 
        Sucs) &
   .concat(Open,Sucs,LT) & 
   .sort(LT,NewOpen) &  // sort by F (H+G), so A*
   //.print("open nodes #",.length(NewOpen)) & //.print(" new open = ",NewOpen) & 
   search( NewOpen, GoalState, Solution).


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users

-- 
Jomi Fred Hubner
Federal University of Santa Catarina
Department of Automation and Systems Engineering
PO Box 476, Florianópolis, SC
88040-900 Brazil


------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Loading...