Author: Ulrich Tuerke
Date: 03:38:53 09/15/03
Go up one level in this thread
On September 15, 2003 at 05:53:40, Peter Fendrich wrote: >On September 15, 2003 at 03:39:33, Uri Blass wrote: > >>On September 15, 2003 at 02:56:24, Reinhard Scharnagl wrote: >> >>>Hi Uri, >>> >>>>Can programmers write a program that take a code with recursive functions and >>>>translate it to a code without recursive functions that does the same thing? >>>> >>>>Do not answer me that the compiler does it by translating it to assembler >>>>because the translation should be done to a program in the same computer >>>>language so a C source should be translated to another C source. >>> >>>it could be done by locally implementing a kind of a stack. You have >>>therefore to think about maximum call limits. Sometimes a simple loop >>>already will do the aimed task. >>> >>>But what is the reason for such a non recursiv approach? What is >>>wrong with using recursion? >>> >>>Regards, Reinhard. >> >>I read that recursion is bad for parallel program and there is information >>that I practically remember twice so maybe it is not good also for non parallel >>program. >> >>If I want to check if the king was in check 2 plies earlier then I need to look >>at a special array for that purpose and I understand that with non recursive >>approach I can get the information without remembering it twice. > >I can't really see the differrence in this respect. If you don't use recursion >you will instead use an iteration (while or for). IMO a very inelegant >solution... >Anyway, You have to put basically all data used locally by the former recursive >function in an array indexed by plynumber. In order to check if the king was in >check 2 plies up you still need to look in the array with the index ply-2. >Am I missing something? "Remember it twice" doesn't make sence to me... That's right. I'd figure out which variables could be interesting on other plies and declare just these as arrays instead of local variables, just as Peter suggest. Everything else can be kept on the stack. IMHO, it's in general a bad idea to implement a search engine non-recursively because the resulting code is much more ugly. Furthermore, C-compilers translate the recursive code quite efficiently. This is a help offered by C-compilers which we should appreciate. BTW, one must be a bit careful when using non-recursive alpha-beta to avoid paying a performance penalty due to lots of array indexing operations. But this can be handled. Programmers using for instance FORTRAN would be forced to use the non-recursive way. In fact, 20 years ago I had been thinking about a chess program in FORTRAN. Uli > >>Uri
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.