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.
[04:59 am]
zsnakezz -- >:)
[04:59 am]
zsnakezz -- :)
[04:58 am]
zsnakezz -- somebody gets it
[04:58 am]
zsnakezz -- and its not all just numbers in my file screen
[04:57 am]
zsnakezz -- thank you for your comment though, good to know some people out there tried my map out
[04:57 am]
zsnakezz -- just kidding
[04:57 am]
zsnakezz -- ultra you have any thought or notes on undead invasion?
[2024-5-31. : 2:36 pm]
Wing Zero -- Bop em
[2024-5-31. : 2:36 pm]
Wing Zero -- Mods
[2024-5-29. : 9:40 pm]
Ultraviolet -- :wob:
Please log in to shout.


Members Online: Roy, Oh_Man