Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Computer chess schools of thought

Author: Sven Reichard

Date: 06:49:54 07/02/02

Go up one level in this thread


On July 01, 2002 at 15:43:49, Russell Reagan wrote:

>I think that if you are allowed access to the "type" of the piece, then you are
>defeating the purpose of OOP. Another example is if you had something like...
>
>vector<int> pieceIndexes[2];
>
>in your position class, then you could just do something like...
>
>pieceIndexes[sideToMove];
>
>when looping through the pieces to generate legal moves. If you don't allow
>acces to the sideToMove data from another outside function (which you shouldn't
>in OOP) then you can't do that kind of stuff.
>
>What do you think?
>
>Russell

OO doesn't say you can't have access to data stored in an object; it does say
that you can't know (and hence can't depend on) *how* the data are stored. And
of course you shouldn't be able to just change the side to move without the
knowledge of the position class. Coming back to the STL examples, of course you
want to know how big your std::vector is (and you use the method size()), but
you don't know the internal representation of the size (in the GNU version, it's
a difference of two pointers, afaik), and you can't just set the size to some
arbitrary value, but you have to call resize() for that purpose.
So, if you make sideToMove a method of your position class, there should be no
OObjections.

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.