I'm trying to shuffle a 2D object array in Java. I thought Collections.shuffle would do the trick, but it looks like it only shuffles the objects in each row, but does not mix rows together, which I wanted it to do. Any built in methods or easy to implement methods that can shuffle a 2D array for me? The array is cards[13][4].
It looks like you want to shuffle a deck of cards.
In real world games, we first shuffle the deck, then distribute the cards to the player. You try to change the order of the sequence: you want to distribute a sorted deck to to the players and ask them to exchange cards until all cards are shuffled ;-)
As Stephen C suggested: collect the cards from the players, shuffle the deck and distribute again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With