Division
Jul 22 2008, 11:28 am
By: Ahli  

Jul 22 2008, 11:28 am Ahli Post #1

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

I need a division for my D1's repairing cost calculations.
general formula:
RepairCost = 0,15 * price * (1 - CurrentDurability / MaxDurability)

how I would calculate in starcraft:
RepairCost =[ [ [price * (1000 - [CurrentDurability*1000] / MaxDurability) ] / 1000] * 15 ] / 100
...this term is equal to the first one and I would have no big problems with to big or to small numbers.

CurrentDurability [1 ; 250]
MaxDurability [1 ; 250]
price [1;999999]

The easiest method I can think of would be subtracting the maxDurability as often as possible from the CurrentDurability and counting it.
But that method may take some time (repair an item has 2 of 3 DUR -> (2000 / 3) /8 -> price calculation takes up to 83 game seconds).
I could copy the division triggers a few times, but it's not worth it.

So, I guess I need another method.

I know that it is possible to divide using binary numbers. So I would have to transfer the durabilities into switches (that's np.).
But I don't think that I'm able to create that system from scratch alone.

Does somebody know exactly how I need to put up that?

Did somebody that already (tuxlar used the long subtracting method in his binary calculator.)?

did spinesheath do that already? He did much math in triggers. Is he still around?




Jul 22 2008, 1:17 pm Clokr_ Post #2



Yeah tux used the long subtracting method. It takes a long while to complete.
I think spniesheath is still somewhat around blizzforums. But I'm not sure. And tux told me once that someone coded a better division algorithm into a map so I guess that it must be him.

Anyway, what you have to implement is this. That is, for integer division. If you want to use decimal numbers the same algorithm would work for fixed point ones.



?????

Jul 22 2008, 4:31 pm Falkoner Post #3



If you use binary count-offs the time factor is shortened like crazy, you can easily get massive numbers to transfer quickly if you use binary count-offs. Of course transferring them variably could be annoying, as you'll need to make copies for every instance of the variable, but once you do one you can use Find and Replace to quickly duplicate it.



None.

Jul 22 2008, 5:16 pm Demented Shaman Post #4



http://www.blizzforums.com/showpost.php?p=185910&postcount=63



None.

Jul 23 2008, 8:57 am Ahli Post #5

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

Thanks :D
this map will help me. I just need to understand the division....
It's in our database now.
I can understand it :omfg:

Post has been edited 1 time(s), last time on Jul 23 2008, 9:42 am by Ahli.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[06:18 am]
Sylph-Of-Space -- No complaints here, i'm just curious!
[11:05 pm]
Ultraviolet -- :wob:
[03:55 pm]
Zoan -- :wob:
[10:34 am]
NudeRaider -- SEN doesn't rely on spammers initiate its sleep cycle. It hat fully automated rest and clean-up phases. Please understand that this is necessary for the smooth operation of the site. Thank you.
[2024-5-18. : 3:45 am]
Sylph-Of-Space -- Does the shoutbox get disabled when there's spammers?
[2024-5-17. : 6:47 am]
NudeRaider -- lil-Inferno
lil-Inferno shouted: nah
strong
[2024-5-17. : 5:41 am]
Ultraviolet -- 🤔 so inf is in you?
[2024-5-17. : 4:57 am]
O)FaRTy1billion[MM] -- my name is mud
[2024-5-17. : 4:35 am]
Ultraviolet -- mud, meet my friend, the stick
[2024-5-16. : 10:07 pm]
lil-Inferno -- nah
Please log in to shout.


Members Online: Sylph-Of-Space