Beispiel #1
0
        public static Board MakeBoard(RulesMatrix topRules, RulesMatrix leftRules, CellState[,] matrix)
        {
            if (topRules == null)
            {
                throw new ArgumentNullException(nameof(topRules));
            }

            if (leftRules == null)
            {
                throw new ArgumentNullException(nameof(leftRules));
            }

            if (topRules.NumberOfRules != matrix.GetLength(0))
            {
                throw new ArgumentException(
                          $"The number of TopRules doesn't match the dimension of the matrix. TopRules: {topRules.NumberOfRules} <> Matrix: {matrix.GetLength(0)}");
            }

            if (leftRules.NumberOfRules != matrix.GetLength(1))
            {
                throw new ArgumentException(
                          $"The number of LeftRules doesn't match the dimension of the matrix. LeftRules: {leftRules.NumberOfRules} <> Matrix: {matrix.GetLength(0)}");
            }

            CellState[, ]? newMatrix = CloneMatrix(matrix);

            return(new Board(topRules, leftRules, newMatrix));
        }
 public FlippedRuleMatrix(IRulesMatrix matrix)
 {
     this.matrix = RulesMatrix.MakeRulesMatrix(
         matrix
         .Reverse()
         .Select(a => a.Reverse().ToList())
         .ToList()
         );
 }
Beispiel #3
0
        public static Board MakeBoard(RulesMatrix topRules, RulesMatrix leftRules)
        {
            if (topRules == null)
            {
                throw new ArgumentNullException(nameof(topRules));
            }

            if (leftRules == null)
            {
                throw new ArgumentNullException(nameof(leftRules));
            }

            return(new Board(topRules, leftRules));
        }