About Squareroot Thingie


Lets get to the point.
Non optimal defence get square root of its defence value counted right?
sqrt of 9 is 3. Fact is that we dont always get 9 ... how about 2?
Almost of the cases, we shouldnt get an pretty entire number.
How does this work?

I know its rahter tribial but still, it bugs me.

What I think is that, when its below 0.5, it will rounded off as nearest
entire number and if its between 0.5-0.9999.... it should get the entire
number above. Say for example, 0.1-4.9999 for 1 and 0.5-0.9999 for 2.
But then thers no use of putting defence value 2, since it gets only 1.41 something.

sqrt2-1.41...apprx.40perc chance of getting 2, 60 perc of case, 1
sqrt3-1.75...apprx.75perc chance of getting 2, 25 perc of case, 1
I guesse this works like this. What do you ppl think?
5,237 views 5 replies
Reply #1 Top
Hi!
But then thers no use of putting defence value 2, since it gets only 1.41 something.

No, it gets 1. The formula is int(sqrt(non-optimal-defence)). After the sqrt-ing the decimal part gets truncated.

BR, Iztok
Reply #2 Top
The formula is as Iztok said. This is the maximum defense you can get, then a random integer from 0 to your max defense is generated, this is your defensive "roll". The attacker also "rolls" a value from 1 (the minimum attack value) to his maximum attack value. The defenders roll is subtracted from the attackers roll and any positive result is the defenders damage.

An example of 100 beam attack against defense of 40 beam, 30 missile and 20 mass driver.

Attacker could roll any value from 1 to 100 assume 51.
The defender rolls beam defense from 0 to 40 assume 20.
The defender rolls missile defense from 0 to 5 assume 3.
The defender rolls mass driver defense from 0 to 4 assume 2.

In this case he defenders damage is 51-20-3-2=26 but is truncated at the current hit points of the defender.
Reply #3 Top

Mumblefatz,

if you take a look to the wiki site on the combat section ( https://www.galciv.wikia.com/wiki/Ship_combat ), you will see that in your case there will be only one defense roll instead of 3. But I am not sure if the defensive roll will be made between 0 and 49 (40 + sqrt(30) + sqrt(20) or between 0 and 47 ( 40 + sqrt(30+20)).

Reply #4 Top
in your case there will be only one defense roll instead of 3

Yes you're correct, thanks for the clarification.

One point in the Wiki article is incorrect and that is both attack and defense can have 0 value rolls. I recently performed a test using a ship with one point of attack in each of the three catagories against a ship with no defense. Over hundreds of rounds the damage was 3 every single time. This "proves" that the minimum attack value is 1 (not that it makes a whole lot of difference).

I am not sure if the defensive roll will be made between 0 and 49 (40 + sqrt(30) + sqrt(20) or between 0 and 47 ( 40 + sqrt(30+20))

I'm not sure either but I would expect it to be (40 + sqrt(30) + sqrt(20)).
Reply #5 Top
That would make programming sense, and in fact be beneficial to the defender since int(sqrt 20 ) + int(sqrt 30) = 9 vs int(sqrt 50) = 7. It could be tested by having a ship with def 1 in each category vs an attacker and check to see if the max defense roll is 3 or 2.