Author: Peter Kappler
Date: 20:32:26 01/25/98
Go up one level in this thread
On January 25, 1998 at 17:55:45, James Long wrote: >A couple months ago I decided to completely rewrite >my chess program "Tristram." One of the things I'm >doing is moving from C to C++. > >Now I'm ready to write some move generation routines. >In previous versions of Tristram, I declared a >global array CHESS_MOVE moves[MAXPLY][MAXPLY]. > >This time I'm thinking about using a doubly linked >list, or even an array of singly linked list >MoveList moves[MAXPLY]. > >This means that every time I wanted to add a move to >one of the list, I'd have to call the "new" routine >to allocate the memory. > >Before I get into it, has anybody tried this before >and found it too expensive? > Constructing new objects on-the-fly is generally very expensive. You should instantiate objects ahead of time whenever possible. In my program I have a 'movelist' class, which contains methods (member functions) for adding, traversing, sorting, scoring, etc. It also contains two move arrays (captures/non-captures) which are filled with move objects at startup. This way I avoid making any calls to the move class constructor at runtime. I don't know how well I explained this. Let me know if it is not clear... --Peter
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.