I have defined a Map in my class storing like position ---> rule
, say:
1--->police
2--->teacher
3--->police
4--->student
What I hope is that every time a player join my game, I can randomly read a pair from that map and get his/her position-->rule
, and then when another joins, get ANOTHER(unique) pair. Is there any good way to acheive that?
What I can figure out is that :
- Convert the map into a entities set
- Convert the set into a list
Collections.shuffle(list);
But I don't think this is a good idea.
PS:
- The key is not integer in the future, but now, it is.
- Every player must own the unque pair.
- I don't want to change my map, which will be still used.