I was going to write a game (it’s called “Qwirkle” if you ever heard of it), in which a two-dimensional playing field stores the position of the stones that the players put into it. The first player puts the stone anywhere, while other players can connect to it from any side (left / right / top and bottom). The playing field itself is not limited to a fixed size, which will destroy the idea of the game. However, the number of stones is limited by the value that the player can determine at launch.
Due to the logic of the game, I need to loop stones with an index. However, since players can add stones from any direction, I need a list that can be expanded in any direction (for example, in the direction of negative and positive indices).
Performance is not negligible, since I need to check several stones in one move.
It would be best to access the stone, for example _stones [-3.5], to access it in position -3, 5, of course.
I thought a stack that could be pushed and pushed from either side (e.g. PushBack / PushFront) would be useful for this, but I'm not quite sure how to implement this in C #.
Are there any predefined lists / stacks like the one I'm thinking of, or is my approach completely weird?
source share