I need a formula for random coordinate dropping (players/monsters, items/gold) around a variable radius. The number of coordinates shouldn't be greater than 33 (4*8+1).
I've had many ideas, and the best I could come up with is creating an array of length radius*8+1, initializing the values in the array to the corresponding array index, and shuffling the values in the array using the Fisher-Yates shuffle algorithm (O(nlogn)). This is extremely time consuming as far as writing the code since I have to test each value in the array for equality 33 times and increment/decrement the testing x and y coordinates for each test.
Is this the most efficient way of doing this? If not, is there an algorithm for a array with a maximum of 33 values that sorts in faster time than Fisher-Yates?
I've had many ideas, and the best I could come up with is creating an array of length radius*8+1, initializing the values in the array to the corresponding array index, and shuffling the values in the array using the Fisher-Yates shuffle algorithm (O(nlogn)). This is extremely time consuming as far as writing the code since I have to test each value in the array for equality 33 times and increment/decrement the testing x and y coordinates for each test.
Is this the most efficient way of doing this? If not, is there an algorithm for a array with a maximum of 33 values that sorts in faster time than Fisher-Yates?