Aug-10-2021, 05:21 PM
Your method for randomly choosing coordinates is very inefficient. Here's a little program that counts how long it takes to randomly select 64 different numbers in the range 1..64.
import random for _ in range(10): used_spots = set() i = 0 while len(used_spots) < 64: used_spots.add(random.randint(1, 64)) i += 1 print(i)
Output:309
478
209
320
306
452
295
221
393
327
You do not put cards back in the deck while dealing a hand, so why not use the same kind of subtractive logic for coordinates. This code makes a "deck" of coordinates and shuffles the deck. To get a random coordinate you just deal the top card.import random random_coords = [r+c for r in 'abcdefgh' for c in '12345678'] # Make list of all coordinates random.shuffle(random_coords) for _ in range(5): print(random_coords.pop()) # Deal the top card