URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       Zerg Hex Forum
  HTML https://zerghex.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: Bug/Exploit Reports
       *****************************************************
       #Post#: 1844--------------------------------------------------
       New banelings spawning time
       By: chudy Date: February 13, 2021, 9:55 am
       ---------------------------------------------------------
       So some banelings spawn 0.1-0.4 seconds faster and some of them
       are delayed by 0.6 and sometimes more seconds(i checked only
       around 10 banelings spawns in the game and i've already found
       some differences). My calculations are based on the code i've
       attached.
       #Post#: 1848--------------------------------------------------
       Re: New banelings spawning time
       By: WMaster Date: February 13, 2021, 2:39 pm
       ---------------------------------------------------------
       Hi chudy,
       Thank you for the post. I've seen the code and by that I can
       tell you are perhaps still a bit new to coding. I'll explain the
       mistake you made as well as explain some coding aspects to help
       you go forward. Your code is certainly a good attempt, but it
       loses some accuracy the more iterations you perform.
       In your code you are using an int variable, which can only hold
       whole numbers. I think you are already aware of this, because
       you did a good job allowing for a fractional part while printing
       the results. The main problem lies with int division discarding
       the fractional result. Meaning 7/10 = 0 and 12/10 = 1. This
       discarded fraction should in an accurate calculation also be
       included with the next increase of +10%. Such fraction could
       become a whole number again given enough iterations.
       Example discarded 0.7:
       0.7 -> 0.77 -> 0.847 -> 0.9317 -> 1.02487
       This number could grow large and would be discarded entirely
       from the end result. And with every iteration there's also a
       high likelihood another fraction gets discarded, increasing the
       error value further.
       To improve the precision you could try a higher internal value,
       for example 450000 to start with and a fractional part of (mod)
       %10000. This would only give noticeable errors with many
       iterations. To only display the first decimal you could
       formulate the expression like (time%10000)/1000.
       However, I would personally go with a 'floating point' variable
       like float or double. Such variables are designed to hold
       fractional parts and can easily do arithmetic with other
       fractional numbers. A double has double as much precision, so I
       suggest using that one. I've re-written your code with this and
       you can notice the difference when they are side by side. I've
       attached the modified code.
       [attachimg=1]     [attachimg=2]
       Also note that in Starcraft 2 there are no fractional parts
       shown in these training times, but they are actually more
       precise.
       A few notes to your coding. You can simply write "time = time +
       time / 10", this will first extract the value out of "time", do
       calculations with it, and after that it puts that result back
       into "time" again, basically modifying the variable in one line.
       There's also something called "compound assignment" which lets
       you write it even shorter.
       Examples:
       "time = time + 10" equals "time += 10"
       "time = time + time / 10" equals "time += time / 10"
       "time = time * 1.1" equals "time *= 1.1"
       Hope it helps. If you'd like some more coding advice/info you
       may send me a private email. Anyway, thanks for the bug
       concerns.
       Cheers,
       #Post#: 1849--------------------------------------------------
       Re: New banelings spawning time
       By: reh Date: February 13, 2021, 4:31 pm
       ---------------------------------------------------------
       For everyone that is confused, here you can try it by yourself:
  HTML http://cpp.sh/2in6k
       Other than that, I just want to say that I like the friendly and
       positive flow of the answer above.
       #Post#: 1851--------------------------------------------------
       Re: New banelings spawning time
       By: chudy Date: February 13, 2021, 6:32 pm
       ---------------------------------------------------------
       Thanks for precise answer and yeah I guess starcraft 2 as a game
       will still cause a lot situations like that if the community of
       the game will be curious enough to check something suspicious,
       at least for them. I was just curious like any person who tried
       to check it. The question was why was the timing of the
       spawn(according to any calculation) and timing on the baneling's
       nest different. I guessed it was a bug but now we all know that
       it's just starcraft being starcraft.
       I knew about float and double but I decided to use int since it
       can do it's job. I was considering to use more precise value
       like you've said but even after using that I would've got a
       different value and it would still look like a bug regardless of
       the code.
       Also I want to thank you for the coding advice since it's going
       to be helpfull in my next years of improvement.
       Wish you luck with improving your game and I guess that's it for
       this type of "bugs".
       #Post#: 1852--------------------------------------------------
       Re: New banelings spawning time
       By: Turb007 Date: February 13, 2021, 7:48 pm
       ---------------------------------------------------------
       [quote author=WMaster link=topic=195.msg1848#msg1848
       date=1613248753]
       "time = time + 10" equals "time += 10"
       "time = time + time / 10" equals "time += time / 10"
       "time = time * 1.1" equals "time *= 1.1"
       [/quote]
       Would highly recommend getting used to writing code like this if
       you plan to pursue coding btw, especially if career-wise as
       writing it otherwise is considered "sloppy" by some
       professionals. Also saves a lot of time writing it as well as
       some computation time in some very large calculation scenarios
       (I had to analyze this for an Algorithms course about a year
       ago).
       #Post#: 1855--------------------------------------------------
       Re: New banelings spawning time
       By: RickSanchez Date: February 14, 2021, 3:17 am
       ---------------------------------------------------------
       Ignoring all the technical parts, how much impact would a random
       variance below 1 second in spawntimes really have?
       We in germany would say it is "Mit Kanonen auf Spatzen schießen"
       basically meaning do excessive actions because of a small thing
       compared to it
       *****************************************************