I started to make a simple domino game. (the one where you place the tiles with same numbers next to each other). I started modelling it and i seem to have landed in a tough spot now. Im modelling the actual domino (called “bone”):
namespace DominoCore
{
public enum BoneOrientation { Horizontal, Vertical }
public interface IBone
{
int FirstValue { get; }
int SecondValue { get; }
BoneOrientation Orientation { get; set; }
}
}
After this type I need to lay them out on the playing field. I made a playing field with square tiles in it:
namespace DominoCore
{
public interface IField
{
IPlayer FirstPlayer { get; }
IPlayer SecondPlayer { get; }
IBoneYard BoneYard { get; }
List<ITile> Tiles { get; }
void PlaceBone(IPlayer player, IBone bone, int startX);
}
}
The playing field has two players and a Boneyard (the dominoes not given to players) and then a list of tiles.
namespace DominoCore
{
public enum BoneExpandDirection { Up, Down, Right, Left }
public interface ITile
{
int X { get; }
int Y { get; }
IBone Bone { get; set; }
BoneExpandDirection ExpandDirection { get; set; }
}
}
Now comes my problems:,
- If I get a domino (Bone) with the value of (1,3) and want to place it on the field, how do I represent the location of where it has been placed (e.g. tile with coordinate 5,5)
- Does the domino tile then expand to the right from 5,5?
- What if I turn it 90 degrees, then the orientation is upward, turn it 180 degrees then its to the left – and the value is now (3,1).
- How do I make this distinction between layout, domino and tile?
I guess at some point I need to figure out, when a player places a tile – to calculate if its legal (search the field for tiles/bones). The various placements of the same domino /bone is shown in image below.
The next problem is laying out the dominos/bones, I am thinking about making a grid, but that doesnt fit with placing a tile “across” (perpendicular) other dominos/bones. When placing a tile I’m back at the first problem: how to validate it its legal? how to find the domino it borders with?
Hope this is making sense – I find it hard to describe the layout and the validation problem im facing.

EDIT
When starting the game the Bones in play are:
[6,6] [6,5] [6,4] [6,3] [6,2] [6,1] [6,0]
[5,5] [5,4] [5,3] [5,2] [5,1] [5,0]
[4,4] [4,3] [4,2] [4,1] [4,0]
[3,3] [3,2] [3,1] [3,0]
[2,2] [2,1] [2,0]
[1,1] [1,0]
[0,0]
Each tile can be reversed this means that tile [6,3] can also be flipped 180 degrees and used as [3,6]
It seems like a grid is a reasonable approach, but it’s a logical grid, and doesn’t directly correlate to the physical layout of the tiles. Assuming the grid is a two-dimensional structure, roughly
Then you need to keep track of the cell that a tile is in and it’s orientation (a byte or enum will do here, since there are only 4 possible values). checking for legality is easy enough- assuming that orientation is an enum:
and you have some class BonePlacement:
Finally,