Live data from Hacker News

Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

reddit.com

31–40 of 267 posts

Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

#31

Earlier quoted context omitted.

> The formula was probably `return new_maxhp * (old_hp / old_maxhp);` ... > Due to floating point rounding errors, convert_hp(1, 55, 55) equals 0.999999940395355224609375, which is less than 1, which means the unit dies. Ahh. The old "Multiplying and dividing is associative... for the set of reals, not for the subset that you can actually afford to compute with." So it should have been `(new_maxhp * old_hp) / old_max…

Could you explain to a noob why does this happen, exactly? Is it because 55/55 != 1, or 1*1 != 1? I understand float can't store certain integer/finite decimal precisely, but why would a/a not be 1 if both numerator and denominator are the same (imprecise) number?

It's neither. Diving 1 by 55 gives some number x where x is arbitrarily (there are standards for how to choose) chosen between the closest 2 representable floats to 1/55. Then, they multiply x by 55. If x is bigger than 1/55 here then the result is > 1. But, if it was rounded down then it will fail because x * 55 will be less than 1.

Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

#32

Earlier quoted context omitted.

Seems all that could have been avoided by using rationals in general and the condition for living being >0 instead of dying The more I write code, the more I notice how rarely one truly should want floats in most kinds of programs and how they almost always carry a whole bag of problems with them.

> Seems all that could have been avoided by using rationals in general It's 2023: I'm still surprised that so many new languages/platforms still only provide only basic integer and IEEE-754 types for numerics: Rust, C#, Java, Swift and others still lack built-in, runtime-provided, nor even standard-library-provided rational types, which I assume really should be the preferred type for most business/domain/application…

Aren't rationals subject to exponential blowup in storage/precision? IMO the best approach for business logic values is picking the smallest meaningful unit and representing it with integers. Precision and storage requirements become very easy to reason about.

Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

#33
post #22
post #14

Earlier quoted context omitted.

Paradox Interactive games, especially the Crusader Kings series also have some pretty entertaining change logs. E.g., from Crusader Kings II, Patch 2.4 [0]: - Handsome and lustful men now also populate the cabins in the wild for the pleasures of people who find them attractive. - Characters who love their spouses very much are now less likely to join holy orders. - Paranoid parents should no longer worry about potent…

Wow, the logic to model these kinds of social structures makes my head hurt. But you would have to do it. And I wonder about dead children. I remember one game where there could be no dead children.

If you don't want to see terrible things happening to children, I'm afraid CK is not the game for you. The game goes out of its way to model the worst aspects of medieval life.

Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

#34
post #22
post #14

Earlier quoted context omitted.

Paradox Interactive games, especially the Crusader Kings series also have some pretty entertaining change logs. E.g., from Crusader Kings II, Patch 2.4 [0]: - Handsome and lustful men now also populate the cabins in the wild for the pleasures of people who find them attractive. - Characters who love their spouses very much are now less likely to join holy orders. - Paranoid parents should no longer worry about potent…

Wow, the logic to model these kinds of social structures makes my head hurt. But you would have to do it. And I wonder about dead children. I remember one game where there could be no dead children.

The logic is less complex than you'd think. It's generally something like "has flag paranoid, has flag child (patched to has flag alive child), then 1% yearly chance of fearing a plot." It feels complex, thinking of the actual logic killed a fair amount of the fun for me.

>And I wonder about dead children. I remember one game where there could be no dead children.

Probably Skyrim, though it's not rare. Crusader Kings somewhat encourages infanticide, as your brother's bastard could stop your character from inheriting a title.

Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

#35
post #2

From the comments: "This was caused by a floating point rounding error. A unit switching jobs internally becomes a different unit (i.e. a monk with a relic becomes a monk without a relic), and when doing that, HP is scaled proportionally based on the old and new max HP using 32-bit floating point maths." And there are YouTube videos about this https://www.youtube.com/watch?v=MytWNbpnAVY

> The formula was probably `return new_maxhp * (old_hp / old_maxhp);` ... > Due to floating point rounding errors, convert_hp(1, 55, 55) equals 0.999999940395355224609375, which is less than 1, which means the unit dies. Ahh. The old "Multiplying and dividing is associative... for the set of reals, not for the subset that you can actually afford to compute with." So it should have been `(new_maxhp * old_hp) / old_max…

> So it should have been `(new_maxhp * old_hp) / old_maxhp`.

I don't see how that couldn't run into similar problems. I would use `clamp(old_hp * (new_maxhp / old_maxhp), 1, new_maxhp)` (assuming that old_hp >= 1).

Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

#36
post #22
post #14

Earlier quoted context omitted.

Paradox Interactive games, especially the Crusader Kings series also have some pretty entertaining change logs. E.g., from Crusader Kings II, Patch 2.4 [0]: - Handsome and lustful men now also populate the cabins in the wild for the pleasures of people who find them attractive. - Characters who love their spouses very much are now less likely to join holy orders. - Paranoid parents should no longer worry about potent…

Wow, the logic to model these kinds of social structures makes my head hurt. But you would have to do it. And I wonder about dead children. I remember one game where there could be no dead children.

And in CK you can actually sacrifice a child for some gains.

Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

#37
post #35

Earlier quoted context omitted.

> The formula was probably `return new_maxhp * (old_hp / old_maxhp);` ... > Due to floating point rounding errors, convert_hp(1, 55, 55) equals 0.999999940395355224609375, which is less than 1, which means the unit dies. Ahh. The old "Multiplying and dividing is associative... for the set of reals, not for the subset that you can actually afford to compute with." So it should have been `(new_maxhp * old_hp) / old_max…

> So it should have been `(new_maxhp * old_hp) / old_maxhp`. I don't see how that couldn't run into similar problems. I would use `clamp(old_hp * (new_maxhp / old_maxhp), 1, new_maxhp)` (assuming that old_hp >= 1).

It could, but only at very large values. It's at least the much more robust solution.

Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

#38
post #35

Earlier quoted context omitted.

> The formula was probably `return new_maxhp * (old_hp / old_maxhp);` ... > Due to floating point rounding errors, convert_hp(1, 55, 55) equals 0.999999940395355224609375, which is less than 1, which means the unit dies. Ahh. The old "Multiplying and dividing is associative... for the set of reals, not for the subset that you can actually afford to compute with." So it should have been `(new_maxhp * old_hp) / old_max…

> So it should have been `(new_maxhp * old_hp) / old_maxhp`. I don't see how that couldn't run into similar problems. I would use `clamp(old_hp * (new_maxhp / old_maxhp), 1, new_maxhp)` (assuming that old_hp >= 1).

If you assume that all three numbers are small integers, doing the division last minimizes precision loss (and doesn't have any loss if the accurate result is representable as a float).

Otherwise you get loss from the division and then multiply that loss (by >1).

Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

#39

Earlier quoted context omitted.

Note that the April 2023 patch is live, and perhaps one of the biggest changes to the meta ever. I don't think anyone really knows how the new meta will shake out. Build orders will absolutely change this patch. Though I guess that only matters if you were hoping to get to a competitive level. Definitive Edition does have a very good tutorial mode for people interested in online combat, and "Extreme" AI is 100% legit…

What’s new? Seems kind of crazy to introduce a meta changing past to an old game like this that has managed to stay popular.

To be fair, it may be the "biggest change ever", but it doesn't change too much. It buff some units that were bad, nerf some units and techs that were too good. But the general meta remains the same. The devs are really good at introducing changes.

Re: Aztec monks with 1/55 HP no longer die when picking up or dropping a relic

#40
It’s great that Microsoft are still actively maintaining a ~24 year old game!

Blizzard ought to take note. A few years back they announced “Warcraft 3 reforged” with great fanfare: a remastered version of the classic Warcraft 3, updated for modern systems with improved graphics etc. It looked/sounded fantastic!

But despite it being a paid upgrade, what they released was a buggy mess that did little justice to the classic original. Then they immediately abandoned it and have released no updates or fixes since.

Post reply on HN