Re: OOP Question
- Posted by ck lester <cklester at YAHOO.COM> Nov 24, 2000
- 358 views
"George" (if that's your real name), > I hope this helps? Is that a question? > I think that position is logically > an attribute of a game piece. And I've considered this, but then what would you do? Have the PLAYFIELD query the piece... "Where are you?" The playfield should know where "its" pieces are! > ...each piece "has-a" position... Say a piece has a position of { 6 , 9 }. That is totally useless information. However, say a PLAYFIELD has a piece on { 6 , 9 }. Now you've got relevance. So, who manages the position? I still believe it is the playfield's. However, remember there's a third object here- the "god" object (no offense). It manages EVERYTHING. This "game" object is composed of a playfield and pieces. Maybe the GAME object manages the positions, TELLING the playfield AND the pieces where they are in relation to each other. Maybe I'm just thinking too much. Anyway, the three options: 1. The piece manages its position - now you have the playfield asking the piece where it is. "Where are you?" 2. The playfield manages the position of its pieces - now you have the playfield telling the piece where it is. "You are here, what do you want to do now?" 3. The game object manages the position of the pieces on the playfield. "You, piece, are at {6,9}. Did you hear that, playfield?" > 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)... I submit that the piece doesn't move (itself), but GETS MOVED. I think it's a crucial difference, no? > capture one another... Again, a piece doesn't capture, it is captured. > To change position, a piece needs to "know" its current > position... You assume that "position" is a property of piece... I can see it being a temporary storage variable, but the piece itself does nothing with it except to remind the playfield where it is... thus eliminating the need for the playfield to store the positions. > and the rules that determine where it can go next... Now this is something with which I agree (grammar gymnastics!)... or do I? Imagine this: You have a bishop piece. You have a chessboard CB1 and another chessboard CB2. CB1 rules stipulate the bishop moves diagonally (ah, normality). CB2 is a bit twisted and stipulates the bishop moves horizontally/vertically! You have the SAME PIECE yet two different movement rules, as defined by the PLAYFIELD. Do you see where I'm going? So, it is not the piece that determines its movement, but the playfield/gameboard/RULES OBJECT. > Its position, seems to me, is a > fundamental characteristic. Nope, because a piece can be nowhere. It is only within the confines of a playfield or rules system that a piece "acquires" any positional relevance. Therefore, it is the piece that is told where it is, it does not tell where it is. > 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... A-HA! You've just validated my position! It is the RULES that determine the move value, NOT THE PIECE. <whew> Thank you. > But I could make a sideways move to a comparable > position in another department, or an > incremental upward move under aprropriate > cursumtances. Well, just as the rules allow that, you can also become a janitor, if ya wanna. > 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. Wrong, you will NOT BE ALLOWED to make a move that goes against the rules, no matter how much you try. And you only know your position as you query your environment... > I hope this helps? Most certainly! Thanks. > Computers save time the way kudzu > prevents soil erosion. -- Al Castanoli What's kudzu again? (I know, I know... look it up.) -ck _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com