I can swap two tiles, however, when I need to shuffle them, I need each tile to have a unique position. I've tried setting up array's for the x and y position of both the tiles to be swapped checking against the randomly generated number to make sure it's position hasn't been taken already but as you could probably tell that was super uneffective.

How would I go about swapping two tiles which haven't already been swapped.

Re: Most Efficient Way to swap Two Tiles 80 80

Do you just want to shuffle all the Tiles?

Put them all in a List and call shuffle()
Then simply re-populate your x,y grid with the Tiles in their shuffled order.

Re: Most Efficient Way to swap Two Tiles 80 80

Thanks! Worked like a charm using Arrays.asList();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.