Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Use of objects and associated performance hit?

Author: Frank Schneider

Date: 22:24:34 12/30/99

Go up one level in this thread


On December 31, 1999 at 00:45:10, Tom Kerrigan wrote:

>On December 31, 1999 at 00:24:32, Peter McKenzie wrote:
>>Slightly off topic, but why do you want to make your engine class a subclass of
>>your board class?  This seems a little weird from an O.O design perspective as
>>usually subclassing implies an 'is-a' relationship (chess engine is-a chess
>>board?!).  More natural to me would be to make the chess board an attribute/data
>>member/instance variable of the chess engine.
>
>Making the chess board a member of the engine class is the obvious thing to do,
>but then every time you access the board, it looks like this:
>
>engine.board.blah
But if you access the board from in the engine-code it looks like
board.blah (or board->blah).
In Gromit I use the board->blah style and I have a macro to access squares
if (...==BOARD(A1))...

>
>If you make the engine class a derivative of the board class, then it looks like
>this:
>
>engine.blah
>
>IMO, the latter is better because the board will be accessed a _lot_ by the
>engine functions.
I would not change the objectmodel just to save the 'board.' sometimes.

Frank

>
>-Tom



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.