Puzzle(byte[][] initialState, boolean restrictions , View view) throws MyException {
		RESTRICTIONS = restrictions;
		int[] availableChips = new int[SIZE];
		for (int i = 0; i < SIZE; i++) {
			availableChips[i] = i;
		}
		
		byte[][] board = new byte[ROW_SIZE][ROW_SIZE];
		for (int i = 0; i < SIZE; i++) {
			if (initialState[i/ROW_SIZE][i%ROW_SIZE] < 0 
				|| initialState[i/ROW_SIZE][i%ROW_SIZE] >= 9) 
				throw new MyException("Chip has bad value (has to be between 0 and 8).");
			
			if (availableChips[initialState[i/ROW_SIZE][i%ROW_SIZE]] != -1) {
				board[i/ROW_SIZE][i%ROW_SIZE] = 
					(byte)availableChips[initialState[i/ROW_SIZE][i%ROW_SIZE]];
				availableChips[initialState[i/ROW_SIZE][i%ROW_SIZE]] = -1;
			} else {
				throw new MyException("Chip is repeated twice.\n");
			}
		}
		
		if (!isSolvable(board)) {
		//	throw new MyException("This configuration is not solvable.\n");
		}
		
		this.board = board;
		this.view = view;
		
	}