Author: Pat King
Date: 15:56:13 09/17/03
Go up one level in this thread
On September 17, 2003 at 13:22:02, Rick Bischoff wrote:
>
>>By the way, I DO use abstract piece classes and a lot of the fancy C++ stuff. My
>>engine is fairly slow, but in my mind it was worth the price because of the ease
>>of testing and debugging individual classes.
>
>It makes absolutely zero sense to do it this way for a couple of reasons. A)
>The pieces on a chess board are limited.. You will never reuse the class You
>will never extend the class. It is basically just "syntantic sugar" that is
>causing you a time penalty in exchange for looking good. I expect that from my
>wife, not my chess program!!
I don't talk to my wife about programming, and I don't talk to you about my
wife!
>(This assumes you are talking about something similar to
>
>class Piece {
>public:
> bool color;
> int square;
> virtual vector<int> moveList(const Board& B) const = 0;
>};
>
>class WhitePawn : public Piece {
>...
>}
>
>etc..
>
Something like that. It makes sense because once I thoroughly tested
class StepPiece: public Piece
{
//...
};
class PromotePiece: public Piece
{
//...
};
I didn't have to worry about
class Knight: public StepPiece, PromotePiece{/*...*/};
at all, and only had to test
class King: public StepPiece, PromotePiece{/*...*/};
for castling behaviour. Did I pay a price? Yes! A heavy one? Yes, to many. Did
my previous versions of Zotron come nearly as far? Hell, no! Extremely thorough
testing was what I needed to progress, and OO is what enabled me to do extremely
thorough testing.
OO is not a silver bullet, but it's at least a bronze one. If I ever expect
Zotron to become world class, I'll have to redo a lot of stuff. But I know that
it will be extremely well tested, extremely solid stuff.
BTW Reuse means more than using your current chess program in your next
spreadsheet program. As I pointed out above, both my Knight class and King class
descend from StepPiece. Interestingly, pawns don't because of their capture
behaviour. The realization that knights' "jumping" behaviour was equivalent to
kings' "stepping" behaviour was a big reduction of time and effort for me.
Pat
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.