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 think I'm completely missing the point here but are you not just wanting to pull random coords near a certain location?... Why would you go through all that trouble of generating all possible coords, shuffling them and then pulling one?
Just do a rand.next using bound X/Y and how far you want the spread.
Sorry if I'm missing the point of doing a more complex version but it does sound to me like you want to just pull a random coord nearby.
I've done a few versions of this... one being pull random coord and then check if it is free but you could just as easily do a for X for Y loop, check if it's free/valid and then return a list of valid coords...
I think I'm completely missing the point here but are you not just wanting to pull random coords near a certain location?... Why would you go through all that trouble of generating all possible coords, shuffling them and then pulling one?
Just do a rand.next using bound X/Y and how far you want the spread.
Sorry if I'm missing the point of doing a more complex version but it does sound to me like you want to just pull a random coord nearby.
I've done a few versions of this... one being pull random coord and then check if it is free but you could just as easily do a for X for Y loop, check if it's free/valid and then return a list of valid coords...
That's what I want to do, but, and correct me if I'm wrong, doing a for X for Y loop, wouldn't exactly randomize the item/gold dropping, and pulling a random coordinate can be inefficient if there are few available spaces on the ground for the item/gold to drop onto.
Actually, do you know which method the official servers use? I assumed that it was randomized, but I'm not 100%.
I'm not sure what method the tq servers use but as for the 'most efficient' way of doing this... probably interfaces + some sort of data structuring the ground items.
The for x/y loop would obviously still need to be randomized (you'd receive a list of valid coords for dropping and then just randomize those which it seems is what you are already doing... but if you wanted to 'cheat' a bit you could store them as an array and just pull a random element 0-elementcount to avoid having some intensive randomization process (we're talking item drop locations here... it's not gotta be absolutely perfectly random lol!)
Personally I like the idea of doing that as it deals with crowded map floors easily.
My map system right now holds a dictionary of ground items using the structure <Coord, list<object>>. That way I ONLY pull coords that have elements on them (mob, player, items, etc) and can write simple methods to pull a list of items on screen or you could reverse that and find empty/non item'd coords.
Release: Spontane sinnlose Idee! Randomized Teleport! 07/29/2010 - Diablo 2 Programming - 6 Replies Imitiert einen Spieler der mit einzelnen Klicks auf sein Ziel zuteleportiert anstatt im Bot-Style direckt drauf zuzuhechten.
Viel spaß beim ausprobieren und zuschauen.
(K.A. ob es auf 3.0 version läuft, sollte aber denke ich.)
Das 3.0 "MyCS_CatchShrine();" fehlt müsst ihr halt noch reinbasteln.
Can you help me? Attack formula !! 01/31/2010 - Aion - 0 Replies - I want to ask about the attack's formula in INFO of the Character when equip weapon .
- And how many defense i need to increase in order to decrease 1 damage.
:confused:
Formula for Steeds Please 07/30/2009 - Conquer Online 2 - 3 Replies What is the accurate formula for steed breeding (the 0.9+0.1 rough estimate isnt gonna cut it for rare steeds).
Dont need a calculator either
Steed Formula 07/30/2009 - CO2 Private Server - 1 Replies What is the accurate formula for steed breeding (the 0.9+0.1 rough estimate isnt gonna cut it for rare steeds).
Dont need a calculator either
[Help]formula.ini function 01/31/2009 - Dekaron Private Server - 2 Replies can any1 help me to explain the function of each line pls..i only know a little such as exp ratio, lvl and stat..it will be much easier for me if i know each of them..where can i edit my server DF time..?
thanks
wMaxLevel ,170
wMinLevelToLoseExp ,0
byStatPointPerLevel ,10
wDropMaxDistance ,180
fItemRatio ,0.5
fSTRDamageRatio ,0.4