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.
[2026-9-25. : 2:22 pm]
Oh_Man -- https://youtu.be/Lfo4C0xzU04
[2026-9-25. : 12:00 am]
Oh_Man -- he hasnt won a single game so far this is hilarious
[2026-9-24. : 11:41 pm]
Oh_Man -- new arty username Rage Against The Machine
[2026-9-24. : 10:14 pm]
Oh_Man -- https://m.youtube.com/watch?v=KPXri8q9ZBs artys vsing the bot now
[2026-9-24. : 8:12 pm]
Ultraviolet -- do you even lift bro?
[2026-9-23. : 5:21 pm]
NudeRaider -- Oh_Man
Oh_Man shouted: NudeRaider yeh thts straight up cheating
the mutas yes, the wraiths probably not. Have you even watched the video? ;)
[2026-9-23. : 12:56 pm]
Oh_Man -- NudeRaider
NudeRaider shouted: Oh_Man Artosis hasn't caught on how devastating the perfect focus fire is. With the mutas he was like "the Mutas always seem to have less hp than against a human". But he didn't notice that the flock he had selected always just had one muta that was hurt. Same with the wraiths here. He's talking about how valks+wraith is gonna destroy Pluto's valks, then 5s later he's dumbfounded the human player's air is just gone and he never figured out why. And for some reason didn't even think to go back and look at the battle.
yeh thts straight up cheating
[2026-9-23. : 12:24 pm]
Oh_Man -- arty's done another vid. he's also announced he's going to organise showmatches with pro, with NO maphacks, so we can see its actual capabilities
[2026-9-23. : 10:09 am]
NimoStar -- It can by playing the same map thousands of times. It is similar to AI speedrunning games
Please log in to shout.


Members Online: JamaL