Aztec monks with 1/55 HP no longer die when picking up or dropping a relic
251–260 of 267 posts
Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic
#252Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic
#253Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic
#254Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic
#255Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic
#256Earlier quoted context omitted.
it's because the calculation (1/ 55) is less than the real number 1/55, so when you multiply it by 55 you get a result less than 1. for an easier to follow example, say you can only work with two decimal places, hp was 1, old max hp was 3 and new max hp was also 3. if you do (3 * 1) / 3 you get 3 / 3 = 1 as intended. if instead you do 3 * (1 / 3) you get 3 * 0.33 = 0.99 which is less than 1
This effect becomes more pronounced, when substracting (but probably also adding) small amounts from big amounts, because more bits are needed to store the big number's more significant digits and floats then lose bits for the less significant digits. That is why, if one needs precision, needs to sort numbers first and then start calculating with the smallest numbers first, working ones way up to the bigger numbers.
Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic
#257Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic
#258Earlier quoted context omitted.
> IMO the best approach for business logic values is picking the smallest meaningful unit and representing it with integers. How would you design an RTS unit stats system to avoid this AoE Monk HP bug using only integer types?
How much health precision do you need? Make hp an int. Or like a /64 fixed point.
Fixed point would not have helped here. Integer would only have helped because dividing first would break immediately.
Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic
#259Earlier quoted context omitted.
> why wouldn’t you also change the damage and other related numbers (such as damage reduction and so on) to percentages as well? Because a sword might do 5HP of damage, not 10% of anyone's damage (whether they've got 50 or 5000HP). Otherwise, hit points are meaningless: 10 attacks with a 10%-damage weapon kills a lowly serf or a mighty dragon. And because damage reduction might reduce a fixed amount of damage from an…
Obviously a dragon doesn’t get damaged at all by a puny little sword. You can’t just say that hitting a dragon with a sword a thousand times would kill it, when none of the attacks can get through the dragon’s armored hide. On the other hand, it will die immediately if pierced by an arrow provided that arrow hits the one spot where the hide is missing a scale. The dragon has 100% DR, except in that one spot.
Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic
#260I don’t understand why they didn’t just use an integer. You can’t have half a HP in AoE and nothing has HP so high that it would overflow a 32 bit integer. Seems like it would avoid a lot of problems.
I had a really fascinating conversation with the lead architect at Frost Giant the other day. They're making the next StarCraft, basically. They don't use floating points. He didn't mention (IIRC) the possibility of rounding bugs; the reason he cited was something a bit more interesting: Floating points are not deterministic, which makes multiplayer challenging, as they simulate game state on each client's computers…