public Grid(short dimension)
	{
		width = height = dimension;
		short squared = (short) (dimension*dimension);
		short squaredMinus = (short) (squared - dimension);
		short[] state = new short[squared];

		for(short i = 0; i < squaredMinus; i++)
		{
			state[i] = 0;
		}
		short j = 1;
		for(short i = squaredMinus; i < squaredMinus+3; i++)
		{
			state[i] = j;
			j++;
		}
		state[squared-1] = -1;

		initialState = new State(state, dimension, (short) (squared - 1));

		short[] finalState = new short[squared];

		ArrayList<Integer> columns = new ArrayList<Integer>();
		for(short i = 0; i < dimension*dimension; i++)
		{
			if((i % dimension)== 1 && i > dimension)
			{
				columns.add((int) i);
			}
		}

		short count = 3;
		while(!columns.isEmpty() && count != 0)
		{
			finalState[columns.get(columns.size()-1)] = count;
			columns.remove(columns.size()-1);
			count--;
		}



		finalState[squared-1] = -1;

		this.finalState = new State(finalState, dimension, (short) (squared - 1));
		initial = new Node(initialState);

	}