Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: C or C++ for Chess Programming?

Author: Sven Reichard

Date: 09:16:02 08/20/00

Go up one level in this thread


On August 20, 2000 at 06:54:22, Dan Newman wrote:

<snip>

>I've always wondered where make()/unmake() ought to go in an object oriented
>program.  I think I'd have a move class and that's where they'd go, but then
>how do you give the move's member functions access to all the state data
>that they need: 1) pass the board and so forth into make(), 2) have the
>board (and other state) be static members of the move class, or 3) make the
>board, etc., global?  Each choice seems to have its drawbacks.  1) makes
>the code cost more cycles that it needs to, 2) begs the question as to how
>other parts of the code are to get to the board, 3) seems to be contrary
>to the OOP paradigm...  I think 1) is probably the best choice.  Just
>pass a pointer to the state data into make().  I guess you end up having
>to do something like this anyway if you want to have a parallel search...
>
>-Dan.

I don't claim that my approach is strictly OO, but here's what I do. I have a
class GameStack (still looking for a better name) which takes care of the
dynamic aspects of the board (which it contains). make()/unmake() are public
methods of GameStack, although the search algorithms usually call
do[First|Next][Move|Capture]. IMO this avoids the drawbacks you mention. For
parallelism you would need one GameStack per thread, though.

Sven.



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.