Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Anyone using STL?

Author: Russell Reagan

Date: 02:30:37 07/26/02

Go up one level in this thread


On July 26, 2002 at 04:44:16, Leen Ammeraal wrote:

>I did not even try vectors to store moves because this
>seemed inefficient to me.

In your expert opinion, do you think that the time it takes to allocate the
small amount of memory for a move list is going to make a big difference in
playing strength of the engine? I have no idea how much time it takes to
allocate memory so I can't really form an opinion.

>Remember, the memory allocated for a vector is usually
>much more than is initially needed, as the 'capacity'
>function shows.

Thanks, I took a look at your example. In most positions you will have around 35
legal moves (or so). That means usually the capacity would get bumped up to 64,
leaving close to half unused. Is the time it takes to allocate 32 move objects
significant (considering it's done over and over)?

>As for storing moves, it seems much better to
>me to use a simple global array and to keep
>track of the index of the first move for each
>ply; in other words, this array is used as
>a stack.

This seems to be a common method, and I'll probably use it if the vector doesn't
work out.

Another poster said that he uses a vector for this purpose, and that it might be
a good idea to call reserve(256) on the vector. There would be less copying,
deallocation, and reallocation, but there would also be more memory that neededo
to be allocated initially, which would likely go unused in most positions. If I
used a vector, would the costs of allocating the extra memory be more than the
reallocation, copying, and deallocation involved in a push_back() on a full
vector?

Thanks for your words of wisdom. They are greatly appreciated.

Russell



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.