Author: KarinsDad
Date: 22:33:48 02/20/99
Go up one level in this thread
On February 20, 1999 at 22:20:22, Will Singleton wrote: >On February 20, 1999 at 01:22:11, David Eppstein wrote: > >>On February 20, 1999 at 00:58:59, Will Singleton wrote: >>> You aren't doing mallocs within the search, are you? >> >>It's actually possible to get away with mallocs in the search, if you reuse the >>malloced nodes rather than freeing them and latter mallocing them again. >> >>I'm not sure I would do it this way again, but my program has an allocated >>struct per search node, with two pointers: one to the child that's being >>searched and one to the first move in the PV. The PV pointers form a linked >>list that gives me the whole PV; the objects in that list have empty child >>pointers. >> >>When a node (x) has a child (y) that lands inside the alpha-beta window, I set >>the new PV simply by something like >> x.child = x.pv >> x.pv = y >> x.child.child = y.child >> y.child = null >>Since I use negascout, this happens very infrequently, but it wouldn't be very >>slow even if it happened more often. >> >>Even less frequently, a child pointer is null and I have to allocate a new one. >>The total number of nodes in all of this linked structure is O(depth^2) so this >>doesn't slow me down much. > > >Very interesting. I don't pretend to know much about programming in general, >being an amateur, so that's interesting stuff. It just sounded odd at first, >allocating memory while searching. I'm sure he's not >de-allocating/re-allocating, so he's likely doing something along the lines you >delineate. > >Will Yes, I am doing something similar, but I still free on occasion within the search (some nodes get re-used, for more recent code, some get malloced and freed, for old code), just because I'm not doing performance yet and it was just going to get re-written anyway when I do the hash code. I haven't even bothered to find out how much of a performance hit this is since it is temporary code. I have a LOT of comments in sections of my code that say things along the lines of: /* And then make the move here on the Child */ /* Yank the malloc once the MoveType memory management is there */ ChildMove->Move = (MoveType *) malloc(sizeof(MoveType)); *(ChildMove->Move) = move; It will be interesting to find out the nodes per second once this is all handled. KarinsDad
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.