Author: Daniel Clausen
Date: 10:02:53 09/15/03
Go up one level in this thread
On September 15, 2003 at 12:54:21, Mathieu Pagé wrote: >Hi, > As I said 2 or 3 weeks ago I have tried to redesign my chess engine in a >object oriented way (in C++). It is done, but ... > > I have some _really_ bad performaces. My code was used to do a perft(5) at a >speed of about 630 000 nps (on a old Celeron 800mhz). Now, the OO version do >about 4500 nps on the same computer and with the same compiler options. Try to allocate the objects in advance, as opposed to on runtime. For example, my move lists (filled from the move generator) are C++ objects (not just a pointer to some allocated integers) but I don't create them again and again (during the recursive search) Instead I pop them from a stack and push them back if I no longer need it. And I allocate a new one if the stack is empty. This way I don't suffer from things like MAXDEPTH (I don't have a fixed number of move lists preallocated) but still don't allocate/deallocate memory all the time. Then of course it depends on what you mean with OO in the context of a chess engine. Some people mean with that more "using C++ as a better C", others design way too much and create abstract piece classes, where the various piece types derive from etc. Of course this way it's not surprising that the engine is slow then. HTH Sargon PS. Measure before you "fix" something :)
This page took 0.03 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.