Author: Peter McKenzie
Date: 02:00:34 01/01/00
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 I take your point, actual code in the engine could look like: board->SetSquare(A2, WP); > >If you make the engine class a derivative of the board class, then it looks like >this: > >engine.blah So actual code in the engine is simplified to: SetSquare(A2, WP); > >IMO, the latter is better because the board will be accessed a _lot_ by the >engine functions. This notational convenience can also be achieved by defining a few inline methods in your engine class. Granted, this isn't as simple as subclassing your engine from your board class but it might not be much hassle as there are probably just a few methods in the board class that are used alot by the engine. I wonder if there are any practical advantages to having the board class a member of the chess engine class. I'm not sure how the rest of your design goes, but you might find it handy to be able to change the position that an engine is searching by a single pointer assignment (eg. engine.board = anotherBoard). Good luck with you new program! > >-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.