Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Mar 27th, 2008, 8:42 PM   #1
Sane
Banned
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,101
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
Techniques For Overcoming Stack Overflow In DP

While constructing an AI for a board game, I've run into a problem that I've now given a good 48 hours of inconclusive thought.

Each turn in the board game has around 10-20 possible moves. Also, there are roughly 20,000 or so different board combinations.

The graph is undirected and cyclical. In other words, you can move back and forth between two board states, and also back to previous board states. Furthermore, as a consequence of having 10-20 possible moves, there's always a way to get to every other possible board setup from the one you are currently on.

This causes a huge issue when running a DFS to solve each subproblem. Even if I force it to be directed and acyclical, the graph can still reach a depth of ~ 20,000 by finding alternate routes to unravel every one of the possible 20,000 setups before even beginning to post-traverse.

And here's the problem: A recursive depth of 10,000 causes a stack overflow.

I was thinking of implementing a queue and BFSing it. However, I need the post-traversal side of recursion in order to express the problem in terms of the result of each subproblem (remember that this is DP and not finding a specific node in a graph).

Logically all 20,000 don't need to be unravelled in one branch. That's just how it ends up when I DFS it. So are there any known techniques for overcoming the problem of a DP graph that unravels very deep subproblems? I need some way to limit the depth, yet still have the subproblems solved in the correct order...
__________________
Looking for tough programming challenges? Try participating in Sane's Monthly Algorithms Challenges!
Composing Techno is a little side hobby of mine. Techno by DJ Sane. All free for download.
Sane is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Heap vs. Stack memory Eric the Red C++ 11 Oct 24th, 2006 7:18 PM
stack question bl00dninja C++ 9 May 8th, 2006 8:54 PM
stack query aloksave C 12 Sep 30th, 2005 5:26 PM
Smashing a stack in MIPS assembly code tsgrimey Assembly 2 Feb 27th, 2005 2:06 PM
Help with stack implementation ridley C++ 0 Feb 26th, 2005 3:26 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:31 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC