Computer Chess Club Archives


Search

Terms

Messages

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

Author: Dan Newman

Date: 15:31:05 08/20/00

Go up one level in this thread


On August 20, 2000 at 12:16:02, Sven Reichard wrote:

>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.

I have an array of structures in my program that I think is probably the
equivalent of your game stack.  I store a lot of the game state there on
a per ply basis, but the board and bitboards are separate and must be
modified both on make() and unmake().  The info that I stuff into the
stack only has to be set on make(), so it saves a little work.  I call mine
the plyinfo array, but like you I'm looking for a better name :).

I could make my board and bitboards static members of the plyinfo class
and then add make() and unmake() as members, but that still isn't quite
right.  I guess I could make a class to hold the stack like you have and
add the board and bitboards to it.  That would allow the multiple copies
needed for parallelism--not that I really want to tackle that one...

-Dan.



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.