Sliding Puzzle Design
Hello,
I am currently creating a tradiational sliding puzzle tile game but I am having problems with some of the design.
In order to create a list of random numbers, I have created a List (Collections API) and initialised it as an ArrayList.
Each element in the list in an Integer object counting from 0 to 15.
I then shuffle this using the Collections.shuffle method.
The problem occurs when I select a lower level (i.e from a 5x5 grid to a 4x4 one).
I have to remove elements thus wasting processing time so that I can shuffle the correct number of elements needed for a 4x4 grid.
The arraylist has to be resized every time a different level is selected.
I guess there no way to shuffle a given range of elements in a collection?
What would be a good solution to the design problem that I am having?
Hope someone can help.
--
Andrew

