Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Design: what would your objects be?

Author: Sune Fischer

Date: 05:41:11 07/03/02

Go up one level in this thread


On July 03, 2002 at 07:57:09, Sven Reichard wrote:

>>FirstOne() - to read the first bit off a bitboard, where should I put this when
>>I don't have a BitBoard class (and I don't see how to make one)?
>
>I don't have bitboards, but where is the problem?
>
>class BitBoard // :public std::bitset<64> ??
>{
>public:
>  Bitboard(unsigned long long);
>  void set(int);
>  void clear(int);
>  bool isSet(int) const;
>  Bitboard& operator &=(const Bitboard&) const;
>  // ..etc.
>  int firstOne() const;
>  operator bool() const; // any bit set?
>};

Wow, didn't know it was possible, I wonder if there are any speed issues here, I
can't have this thing dragging me down :)

>>SetupMisc() - things like hash, killer and history tables, flags for
>>communication  and all kinds of things. It doesn't really belong anywhere IMO.
>
>In the constructors of the hash, killer, and history tables. Also, a method
>Algorithm::setUpSearch() could be useful.

No I don't have classes for these, again because I find it a bit silly.
There is only one Killer object and i don't have any functions working on the
killer table. The class would just be empty, except for the constructor of
course :)
Entirely the same for the history table, though maybe some things would be
practical to jam into functions (I tend to use macros instead).

Now the hash is intuitively more a class type object IMO and I have declared it
as a class, but I have two hashes, a pawn- and regular hash and they are not the
same in regards to member variables. The size of these elements must be as small
as possible, so I need two hash classes (unless you can teach me a new trick
here:).

The problem for me is, that I need to dynamicly allocate the size of the table,
and I'm not sure how to make the hash a global object while at the same time
calling its constructor when doing the dynamic allocation.
It seems easier to bypass the constructer, and then manually memset the thing
just after allocation.
I really need the hash to be global I think, I don't want it inside my Tree
because I could have more instances of the Tree (in a parallel search for
instance), but I would never want more than one instance of the hashtable.


>>isDraw() - checks for repetition (needs the Tree) and checks for material (needs
>>the Board). Should I make a special evaluation class, seems it would always and
>>only depend on the Board.
>
>It depends also on the tree (as you said). I deal with repetitions in an extra
>class, and have that called in the evaluation class.

Hmm, but there is no meaning to the object of an evaluation class.
What _is_ such an object, other than a collection of functions?
The evaluation is connected/related to the Board and not much else, so why
seperate them in two classes?

>>One of the things I always get stuck with in this OOP is that some things feel
>>like they should be put into their own class, but there is never any use for an
>>object of the class, other than to call those functions. For instance I have
>>functions to make random numbers, to convert ASCII characters, that sort of
>>simple things. I wouldn't know what to do with a 'random' object, I just need
>>the random number, not the object. It means I first must declare a random object
>>to get a random number, pretty silly IMO.
>
>Three possibilities:
>a) Put the random number function in a namespace by itself, or equivalently,
>make it a static method of a Random class. That way you can be sure nobody
>messes with your state.

The static thing is just as bad as the declaring of an object IMO, it is very
messy to look at, you need to access the functions like RANDOM::gen_rand_64();,
I will never fall in love with that syntax:)

The namespace thing is just a fancy word for a global object, right?

>b) Make a random number generator an object, then you have to create it first in
>order to get random numbers. If you're interested in that, you get thread safety
>that way.

I'm not sure how to do that, you see there are holes in my OO-knowledge
everywhere :)

-S.



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.