Computer Chess Club Archives


Search

Terms

Messages

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

Author: Daniel Clausen

Date: 02:37:11 07/03/02

Go up one level in this thread


On July 03, 2002 at 04:57:05, Sven Reichard wrote:

>Russell,
>
>I admit that have taken the OO approach a bit to the extreme, so I have
>classes for all sorts of silly things.

I think it's worth a try. :) Last time I rewrote my engine I wanted to go from C
to C++ but I feel that 'I didn't do enough OO...'. I do have things like a board
class, and methods like 'toFEN()' or 'toString()'. But for example when it comes
to generating moves, I don't use a dynamic (or at least bounds-checking)
move-list. I assume you do that, Sven. :)

Also the search function was moved in a class but it's just a static method for
now. I'm thinking about changing this method to a non-static method. This way
the things like 'numberOfPositionsSearched' could be an attribute of the class,
but I'm sure yet, it's a good design. (there are also counters for acessing the
hashtable (in the future), evaluation-related etc. and I'm not sure where the
best place is to put them - at the moment I have a Statistics class which has
all these counters are static attributes. And I have to call reset() to reset
them all before I start with a new root-search... not very elegant I think...)


>The names of the classes are important, and you don't see how silly they are
>until you show them to somebody else. I like the name Board, since the board
>contains the pieces, and that's it. Have to rethink "Game". I just recall that
>at some point it was called DynamicPosition, since it contains the board
>position(the static part) and some "dynamic" part, i.e., side to move etc.,
>however I thought that name was ugly. Also, SanNotation is silly since SAN
>stands for short algebraic notation...

I my case, I have:

(a) Class Board
Contains information which piece resides on which square, but also contains
information about en-passant, castling state etc. I guess I could have called
the class 'Position', I just somehow prefer 'Board'.

(b) Class Game
Has Board as a member variable, along with other information about a played
game. For example it contains information about time limit for both sides and
player names. It also contains a move list, which contains all played moves so
far. (therefore you can undo a move on a game-object, but not on a board-object)

Sargon



This page took 0.01 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.