So I have a method that randomly places pieces on a board. The method uses the rejection method where it will create a random number to place the piece on the board, but if the place is already taken it will try again. The problem with this method is that if I have a lot of pieces to place it is very slow. (Like 40 pieces and 50 spaces)
How can I make this kind of method run faster no matter how many pieces or spaces there are?
How can I make this kind of method run faster no matter how many pieces or spaces there are?