Author: Robert Hyatt
Date: 08:33:40 12/03/02
Go up one level in this thread
On December 03, 2002 at 04:08:17, Daniel Clausen wrote: >On December 02, 2002 at 18:14:25, Robert Hyatt wrote: > >[snip] > >>A dynamic array is bad from the get-go, for performance. OK for designing >>things of course. But for chess, inside the engine, no... > >It depends very much on the implementation. > >The class could internally for example take chunks of a preallocated array and >use that for storing the moves. (the size of the chunk being >MAX_NUMBER_OF_MOVES_IN_A_POSITION) This way you have a clean interface and all >the hacks like the aforementioned MAX number and/or array-bounds checking is >inside the class, where you can easily change it later in the development >process. You still have to do garbage-collection as you can malloc and free out-of-order and end up with a fragmented memory space in the array... > >Another possibility is to create N movelist objects before the actual search >begins and 'retrieve' the movelists when needed. (can either be an ugly array >again w/o bounds checking, or can be inside a factory class, or a pool class >(the pool could grow in size if needed, or could throw an exception or >whatever)) That's the solution I currently use in my engine. (IIRC - it's been a >while since I worked on it.... *sigh*) > >I'm sure other things are possible.. There are many things between 'being an >OO-purist' and 'fiddling around with global arrays w/o bounds checking and >hoping for the best'. :) And the speed difference doesn't have to be 10 when >carefully designing the stuff. > >I agree though that many new/allocs during the search simply kill you. :) > >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.