public Puzzle(int n) { if (n < 2) { throw new ArgumentException("puzzles count should be at least two!"); } InitialState = new State(n); GoalState = new State(MatrixCalculations.GetMatrix(n, n)); CurrentState = new State(InitialState.state); }
public State(State parent = null) { if (parent != null) { state = new int[parent.state.GetLength(0), parent.state.GetLength(1)]; Array.Copy(parent.state, state, state.Length); this.Parent = parent; } else { state = MatrixCalculations.GetMatrix(3, 3); MatrixCalculations.Shuffle(state); } }
public State(int n) : this(MatrixCalculations.GetMatrix(n, n)) { }