You must be logged in to post messages.
Please login or register

Age of Empires / Rise of Rome / Definitive Edition
Moderated by Suppiluliuma, PhatFish, Fisk, EpiC_Anonymous, Epd999

Hop to:    
Welcome! You are not logged in. Please Login or Register.15 replies
Age of Empires Heaven » Forums » Age of Empires / Rise of Rome / Definitive Edition » f@#!$@%&#%^~!@$@^& (Nobility and Egyptian Nobility Bugs)
Bottom
Topic Subject:f@#!$@%&#%^~!@$@^& (Nobility and Egyptian Nobility Bugs)
Rasteve
Clubman
posted 08-07-09 07:44 AM ET (US)         
Nobility
You may be aware that the nobility tech doesn't increase hp by 15%. This is because of 2 reasons:

1. The "1.15" multiplier used to create the 15% bonus takes the form of a floating point during the calculations. Now, mathematically we can say an infinite amount of numbers may exist between say 1.14 and 1.15 (1.141, 1.142...1.1401 etc). Using binary to represent such numbers is troublesome as there are only a limited amount of numbers which can be represented accuractly. In this case it is possible that "1.15" actually gets corrupted to become something like 1.149999... So for the chariot, the hp = 100 but multiplying by 1.149999... gives us the result 114.9999... rather than 115 (expected).

2. Secondly, the reporting of hp values (on screen) goes from a floating point value to an integer, and this transformation will chop off the decimal. So for the chariot the 114.9999 becomes 114.

Egyptian Nobility
Now to make things more complicated Egyptians have another strange bug whereby the hit points for chariots after nobility is different depending on whether the nobility tech was researched by the player or given as free (such as with an iron age start).

This is because the "1.149999..." multiplier is applied after the "1.33" civ bonus multiplier when researching nobility for yourself, or alternatively the "1.149999..." multiplier is applied before the "1.33" civ bonus multiplier when nobility is automatically researched (iron age start etc).

Now, knowing maths you should say "hey it doesn't matter which order multiplication is done in", which is true, except in this case the decimal is chopped off after each multiplication (so it isn't the simple case of A * B * C = A * C * B).

What does this all mean?
Well, you are being cheated out of 1hp for standard civs researching nobility.

Egyptian pre-nobility scythes (only possible via scenario editor) lose 1hp

Egyptian post-nobility chariots lose 1hp, CA lose 1hp, scythes lose 2hp

Furthermore, a placed egyptian iron age chariot has 1hp less than an egyptian player researching nobility for themselves.

What should I do?
Contact your local tax office detailing the problem. You will need the number of times you have researched nobility and the number of chariots (by type) you have trained after nobility was researched. Also specify if you were Egyptian in the nationality column. Compensation will only be paid out on a first-come first-served basis. Please quote your Zone id.

[This message has been edited by Rasteve (edited 08-25-2009 @ 07:04 PM).]

AuthorReplies:
EME2940820
Clubman
posted 08-07-09 12:52 PM ET (US)     1 / 15       
Very perceptive, Rasteve. I will have to check this one out.

I wonder if analogous situations occur for the following: Phoenicia's wood gathering rate with respect to the Woodworking, Artisanship, and Craftmanship; Egypt's gold gathering rate with respect to Gold Mining; and Babylon's stone gathering rate with respect to Stone Mining. These would all be much more difficult to test.
Rasteve
Clubman
posted 08-07-09 12:56 PM ET (US)     2 / 15       
I would say near impossible to test! Actually, the civ bonuses and tech upgrades you have mentioned are not multiplied but rather added, therefore it is less likely that the same kind of problem exists. However, a different problem exists - incorrect documentation:

http://aoe.heavengames.com/cgi-bin/aoecgi/display.cgi?action=st&fn=1&tn=5855&f=1,5855,0,10&st=25
Post 31
Suppiluliuma
AoEH Seraph
posted 08-09-09 11:00 AM ET (US)     3 / 15       
You're saying that in custom scenarios nobility changes hitpoint of egyptian chariots as if they had normal (i.e. non egyptian) hitpoints? what happensa if one starts a Random game from stone age? Does the same happen?

What are your results? What are the expected HPs and the real Hps for egyptian chariots (considering the hp bonus was considered before nobility)?
Rasteve
Clubman
posted 08-09-09 01:21 PM ET (US)     4 / 15       

Good ol' fashion Nobility
Chariot100 to 114
CA 70 to 80
Scythe 120 to 137
cav 150to 172
heavy 150 to 172
cat 180to 206
cam 125to 143
scout 60 to 68
ha 60 to 68
hha 90 to 103

Egyptians pre-Nobility
Char 100 to 133
CA 70 to 93
Scythe 120 to 159

Egyptians +Nobility (researched)
Char 152
CA 106
Scythe 182

Egyptians Iron/Post-Iron Nobility (scenario builder)
Char 151
CA 106
Scythe 182


Expected Results
I was expecting nobility to increase hit points via multiplication (*1.15), Egyptian or not. Egyptian bonus should be applied as *1.33 (33% bonus), which if you round down it does. However, as nobility goes through some strange rounding routine, it messes things up for egypt.

As for the order in which things are done, multiplication should yield the same results whether *1.15 * 1.33 or *1.33 * 1.15. But as nobility isn't applied as a clean multiplication (results indicate a rounding then subtraction of 1) then the order does matter (i.e. each order gives different results).

Strangly, nobility and the egyptian bonus should be applied in the same way. They are both set up to multiply the target units by 1.15 or 1.33 - but only nobility actually goes through a different process.

Babylonian/Shang wall hit points doesn't go through this process but I believe the yamato boat hp bonus does (just testing now).


Possible Causes

As yet I cannot see anything which really sets the nobility and egyptian bonus apart, or something that nobility (technically) has in common with yamato ship hp bonus that egpytian chariot hp bonus doesnt....
The Dark Archer
HG Alumnus
posted 08-09-09 11:27 PM ET (US)     5 / 15       
Hmm. This may be because of the way computers work. I would guess that hit points are represented by integers in which case if they are put though a calculation that leaves them with decimals then the decimal part will just be chopped off (i.e rounded down). However I'm not sure why there is a missing hit point from the scenario editor Egyptian Chariot.

The Dark Archer

"Try not to become a man of success but rather to become a man of value." - Albert Einstein
"I once met a girl who looked like a camel" - Rasteve
Death of the Morads | AoEH Design Series II | Out From the Cliffs
Rasteve
Clubman
posted 08-10-09 01:58 AM ET (US)     6 / 15       
Take the chariot for example (100 hp). Nobility should multiply it by 1.15 (15% increase) to achieve 115 but you end up with 114. I can only see 2 reasons:

1. All nobility removes 1hp as part of a process?
2. The multiplication is buggy and you end up with say 114.99999... which is then rounded down?
Fisk
Champion of AoEH
(id: Fruktfisk)
posted 08-10-09 04:24 AM ET (US)     7 / 15       
Here's the techage slot for nobility:

techage_34_name: A01
techage_34_count: 5
techage_34_0_type: 5 (Multiply)
techage_34_0_unit: -1
techage_34_0_class: 12 (Cavalry Units)
techage_34_0_attribute: 0 (Hit Points)
techage_34_0_amount: 1.15
techage_34_1_type: 5
techage_34_1_unit: -1
techage_34_1_class: 35 (Chariots)
techage_34_1_attribute: 0
techage_34_1_amount: 1.15
techage_34_2_type: 5
techage_34_2_unit: -1
techage_34_2_class: 36 (Horse Archers?)
techage_34_2_attribute: 0
techage_34_2_amount: 1.15
techage_34_3_type: 5
techage_34_3_unit: -1
techage_34_3_class: 23 (Chariot Archers)
techage_34_3_attribute: 0
techage_34_3_amount: 1.15
techage_34_4_type: 1
techage_34_4_unit: 21
techage_34_4_class: 1
techage_34_4_attribute: -1
techage_34_4_amount: 1

Stuff within brackets refers to the numbers before them. I have no Idea what the last effect is, but it seems to exist in a lot of other techs. It doesn't seem to do anything.

//The warrior of Isola

"I lack quotes that demonstrate Humor Intelligence or anything about me."

Pineapplefish
Cleidopus gloriamaris

[This message has been edited by Fruktfisk (edited 08-10-2009 @ 04:25 AM).]

Rasteve
Clubman
posted 08-10-09 04:28 AM ET (US)     8 / 15       
I can help you with this

techage_34_4_type: 1
Change player attribute (such as resources etc)


techage_34_4_unit: 21
Technology count


techage_34_4_class: 1
Add


techage_34_4_attribute: -1
Not used


techage_34_4_amount: 1
+1
Fisk
Champion of AoEH
(id: Fruktfisk)
posted 08-10-09 04:48 AM ET (US)     9 / 15       
Oh... That's it. Thanks Rasteve.

Anyways the techage slot doesn't indicate anything about subtracting 1 hp...

//The warrior of Isola

"I lack quotes that demonstrate Humor Intelligence or anything about me."

Pineapplefish
Cleidopus gloriamaris
Rasteve
Clubman
posted 08-10-09 04:57 AM ET (US)     10 / 15       
Yes, which makes it strange why units such as chariots hp (100) * 1.15 result in 114 (s/b 115!!!!).
The Dark Archer
HG Alumnus
posted 08-10-09 05:20 PM ET (US)     11 / 15       
I'd say it is probably something strange in the algorithm they used.

The Dark Archer

"Try not to become a man of success but rather to become a man of value." - Albert Einstein
"I once met a girl who looked like a camel" - Rasteve
Death of the Morads | AoEH Design Series II | Out From the Cliffs
Rasteve
Clubman
posted 08-11-09 05:51 PM ET (US)     12 / 15       
Here are my conclusions on the nobility bug:

Pick any 2 numbers, no matter how close, and mathematically there are infinite numbers in between. When trying to represent such numbers in a machine we are restricted to the number of bytes, and therefore it is expected by experienced programmers that certain calculations can yield inaccurate results. Or another way of looking at it, the one binary code representing a multiple range of numbers.

One example I found was the following snippet from C++

double a=111.567,b=111,c;
c=a-b;

We are expecting c to equal 0.567.

But during the calculation a becomes 111.56699999999999, b becomes 111.00000000000000 and c becomes 0.56699999999999307

Now applying this to say Chariot hit points we could have the following snippet of code (I am just speculating here)

double a = 100, b = 1.15, c;
c = a*b;

But instead of c = 115 (as we can show with any old calculator) we have 114!!

Ok, so maybe in this case a becomes 99.9999999...
Then c = 114.9999...
Finally the answer c is converted back to an int (like darky stated, the decimal is dropped) to give 114.

As much as it is a C++ (or any other language as far as I am aware) issue, there are methods which can solve this issue (such as using a mathematical library which deals with such occurances).

Actually, as the issue with nobility consistently knocks 1 off the expected results, I'm guessing the 1.15 becomes 1.1499999999....


On ES part, I have no doubt they were aware of this issue. Many of the bonuses quoted in the manual are stated as percentages, which naturally should be applied via multiplication. However, ES avoided at all costs to use multiplication unless forced (most bonuses are applied via addition). Nobility requires multiplication due to the Egyptian chariot bonus.

Darky, I can remember previously that you had experience with Java. Does this sound familiar? Maybe the math library works around this, but in C++ the issue is known, and it is up to the developer to create a work around.
The Dark Archer
HG Alumnus
posted 08-11-09 10:30 PM ET (US)     13 / 15       
It certainly sounds possible. I personally haven't run into the problem with using C++ but computers are such complex things that bugs like this occur. Also it is very possible ES knew about the problem but viewed it as a very small one that wasn't worth the effort to try to fix.

The Dark Archer

"Try not to become a man of success but rather to become a man of value." - Albert Einstein
"I once met a girl who looked like a camel" - Rasteve
Death of the Morads | AoEH Design Series II | Out From the Cliffs
Rasteve
Clubman
posted 08-12-09 08:39 AM ET (US)     14 / 15       
If you ever do mathematical calculations in C++, be aware of conversion to and from floating point numbers. I have read a little more into it today and it seems to be a very well known problem with industry-programmers.

I may load up netbeans today and plug the nobility values in to see if I can replicate this bug.
Rasteve
Clubman
posted 08-25-09 07:04 PM ET (US)     15 / 15       
updated
You must be logged in to post messages.
Please login or register

Hop to:    

Age of Empires Heaven | HeavenGames