Re: OOP Question

new topic     » goto parent     » topic index » view thread      » older message » newer message

Tongue-in-cheek suggestion for an OOP solution (fufills the letter of
OOPness, if not the spirit):

Create an "Omniscient Programmer" object, and have all the other objects
that need to "know" the position of the pieces query the programmer as to
their whereabouts.

Seriously, I think that position is logically an attribute of a game piece.
Of course, position is relative to the playfield and the game and everything
else in the universe, but each piece "has-a" position that is uniquely its
(unless your game allows two pieces to occupy the same position; maybe I
should write, "characteristically its" -- then again maybe not, 'cause
that's too hard to type...).

What active part does the board (playfield) take in a game, unless the board
has wormholes that randomly appear and transport pieces to other positions
on the board? Pieces, on the other hand, do lots of interesting stuff like
move (change position), capture one another, etc. depending on the rules of
the game.

To change position, a piece needs to "know" its current position and the
rules that determine where it can go next. Its position, seems to me, is a
fundamental characteristic. Hmm, it's like my position at my job. I know my
position. The rules prevent me from becoming president of the company
tomorrow, or from suddenly deciding I want to be the janitor; But I could
make a sideways move to a comparable position in another department, or an
incremental upward move under aprropriate cursumtances. So I (an actor in
the dynamic life of the company, as I conceive of a piece being an actor in
a game) will not try to make a move that violates the rules, based on a
clear knowledge of my current position.

I hope this helps?
George Henry

Computers save time the way kudzu prevents soil erosion. -- Al Castanoli

_____________________________________________________________________________________
Get more from the Web.  FREE MSN Explorer download : http://explorer.msn.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu