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.

Recommended Answers

All 2 Replies

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.

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

Be a part of the DaniWeb community

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