Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Solving the "constructor" problem in C++

Author: Jon Dart

Date: 12:56:54 06/12/02

Go up one level in this thread


First of all, you should run the profiler to see if this is actually a
significant problem.

Besides the choices mentioned so far (using malloc, or making Move a primitive
type such as int), you could easily pre-allocate a move array. All you need is
an array Move[MAXMOVES] for each ply depth - so you can do:

Move **moves = new Move * [MAXPLY];
for (int i = 0; i < MAXPLY; i++)
  moves[i] = new Move[MAXMOVES];

This can be done once at initialization.

then in each call to the search routine, you access the move array for current
ply via

Move *currentMoves = moves[ply];

You just overwrite any previous contents, because they belong to another branch
of the tree you've already searched.

--Jon



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.