Author: Miguel A. Ballicora
Date: 08:03:51 05/13/02
Go up one level in this thread
On May 13, 2002 at 05:32:07, Daniel Clausen wrote: >On May 13, 2002 at 00:22:28, Russell Reagan wrote: > >>If I have one legal move array, will that work for searching recursively? For >>example, in AlphaBeta() where it says GenerateLegalMoves(), if I have a global >>variable that won't work, at least it doesn't seem like it would, because you >>would be writing over the moves from previous plys. So it would seem like you >>would need a local variable for this. But in TSCP it looks like Tom used a >>global legal move list in gen_dat[] but he also has a first_move[] array that >>could do something to make this work. I think I get the general idea, but I'm >>not very clear on it. >> >>It seems like a simpler solution would be to use a local variable inside >>AlphaBeta() to store the legal moves, then they would be saved on the stack >>during recursive calls. Is there any downside to this method? > >I'm not quite sure why people use the approach of using a global array and a >first_move[] array really. Basically it's a stack. Since there already is a >stack, I prefer to use this one rather than implementing my own. Note that >allocating space on the stack doesn't really cost anything, as long you don't >initialize the array each time. (luckily C doesn't do this by default with local >variables) I guess you can gain some NPS with the global array approach, but >IMHO it's not worth it. YMMV, as always. If I am not confused with the question, a local variable is a waste of memory because each call you have to spend the maximum number of moves (256 is a safe number). With a global stack "ad hoc" you just use what you need and I do not think is much more difficult. I wonder if this does not hurt cache efficiency (to have lots of "holes" as unused memory in the stack, in a highly recursive program). On the other hand, If you have a machine that does not have a lot of stack memory (as it was true in the near past), the choice is obvious. I do not use any of these two methods. I use my own memory storage allocator that internally works as a stack, so deep down it is more similar to having a global stack but in the surface looks different to both methods. I did it in this way before learning how other people do it, then I decide it to keep it because I saw no reason to change it. In fact, it is quite readable. That is part of the joy of writing a program without looking at other people sources. Sometimes you come up with a solution that looks different, but sometimes you rediscover the wheel :-) (but you learn A LOT). Regards, Miguel > >Similarly I don't see why people use this triangle array for the PVs. I prefer >the straightforward solution as Bruce also explains on his excellent web page >(http://www.seanet.com/~brucemo/topics/pv.htm) It's crystal clear, doesn't give >me any headaches and is maybe a few NPS slower. So what. > >Sargon
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.