I am designing a chess-like game but I believe this question can be extend to all games that have battle.
So my question is, how should I properly label an object as a
friend
object or anenemy
object in a battle game?
Take chess for example. If player W plays white pieces, then W's opponent, player B, plays black pieces.
For W, all white pieces are friend
objects and black pieces are enemy
objects, while player B has black friends
and white enemies
. So here my labeling problem can be simply solved by using colors. When you try to calculate the possible moves of a piece and decide if you can take out a piece, you can basically check if they have the distinct colors.
However, what if two players have the same view? For example, a game can color all friends
as black while color all enemies
as white, and the players start their games with their pieces all at the bottom. In this sense of speaking, indeed, pieces can be viewed as the attributes of the player. So the coloring of black and white is based on whether a piece has an owner id that is the same as yours.
Here comes a problem:
Although I can decide the color by comparing the ids, what if I want to know whether a
friend
piece enters theenemy region
?
The definition of enemy region
could be the upper part of the board. Since board is not part of the player (while pieces can be), it is not possible to use the previous id solution.
So one possible solution I can think of is to make the board an attribute of the player. However, there are two players, this doubles the data storage because we have actually only one board from an objective perspective. And any moves and further changes on a piece requires operations on two boards, which is also time consuming.
In order not to double the board, I try use to another strategy, which is to use a landscape view. What I mean is that, the data doesn't take sides as players. Players view the board from bottom to top, while data can be viewed from left to right/right to left like what a just referee observes. So the data becomes objective here. But the problem is how to present the objective data in a subjective manner to players? And it is still not easy to know if a piece enters enemy region.
So my question is, how should I properly design the data structure, so that it does not doubles or triples or copies multiple times of the data, and in the meanwhile, it is also easy to know the labels of a public area? In my question, the public area is a chess board, where all pieces should fight on this single board. I call it public because both players can move their pieces to everywhere on the board, and third parties can also see what's going on the board. But the labels of pieces are just subjective attributes, personal private thoughts.
I am not sure if I can properly explain/phrasing my question well so I didn't search for a similar question. Sorry for my laziness. If there is a duplicate question that has been asked, please guide me to it.
Aucun commentaire:
Enregistrer un commentaire