public void AddColumns(int xOffset, int yOffset, int xSize, int ySize, int xWidth, IConstraints <int> constraints) { for (int x = 0; x < xSize; x++) { Keys <int> group = new Keys <int>(); for (int y = 0; y < ySize; y++) { group.Add(1 + x + xOffset + ((y + yOffset) * xWidth)); } string name = string.Format("Column {0}: At {1}", x + 1, x + 1 + xOffset + (yOffset * xWidth)); IConstraint <int> constraint = new ConstraintMutuallyExclusive <int>(name, group); constraints.Add(constraint); } }
public void AddGrid(int xOffset, int yOffset, int xSize, int ySize, int xWidth, IConstraints <int> constraints) { Keys <int> group = new Keys <int>(); for (int y = 0; y < ySize; y++) { for (int x = 0; x < xSize; x++) { group.Add(1 + x + xOffset + ((y + yOffset) * xWidth)); } } int xGrid = xOffset > 0 ? (xOffset / xSize) + 1 : 1; int yGrid = yOffset > 0 ? (yOffset * xWidth) / ySize + 1 : 1; string name = string.Format("Grid {0},{1}: At {2}", xGrid, yGrid, xOffset + 1 + (yOffset * xWidth)); IConstraint <int> constraint = new ConstraintMutuallyExclusive <int>(name, group); constraints.Add(constraint); }