Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#2446 closed defect (fixed)

Rounding problem in AI maxHitpoints for hele civs, making some units idle

Reported by: mimo Owned by: mimo
Priority: Should Have Milestone: Alpha 19
Component: AI Keywords:
Cc: Patch:

Description

in common-api/entity.js the maxHitpoints of hele civs is a "not rounded" float, causing problems with the function isHurt. This lead to builders staying idle near their finished building (the AI thinks the building is not finished while the simulation has it finished). I've not been able to trace why this seems to happen only for the different hele civs ?

Change History (17)

comment:1 by wraitii, 10 years ago

Milestone: BacklogAlpha 16
Owner: set to wraitii

I'll give this a look, thanks.

(BTW while I'm at it thanks for the many AI bugfixes)

comment:2 by mimo, 10 years ago

r14864 contains a hack to temporarily cure the problem, waiting for a proper fix (see change in the isHurt function).

comment:3 by Stan, 10 years ago

can't you just use Math.round((this.hitpoints()) ?

comment:4 by mimo, 10 years ago

What do you mean exactly ?

  • if a fix to simulation ? can you be more explicit on where you would put this Math.round and why this problem is seen with hele civs
  • if a temporary hack on the ai side ? i've already implemented one which fulfills the ai needs

comment:5 by Yves, 10 years ago

I'm quite sure #2460 has the same cause.

comment:6 by Stan, 10 years ago

Well instead of this isHurt: function() { return (this.hitpoints() + 1) < this.maxHitpoints(); },

isHurt: function() { return (Math.round((this.hitpoints())) < this.maxHitpoints(); } to replace the tweak in http://trac.wildfiregames.com/changeset/14864

comment:7 by wraitii, 10 years ago

I'm pretty sure this is a problem with technologies being wrongly registered or something. Might be wrong though, it's been a while since I looked at it.

comment:8 by Stan, 10 years ago

Should we push it to A17 ?

comment:9 by mimo, 10 years ago

stan That would have been a possibility, but I've seen cases where the not rounding issue was bigger than 0.1 so as long as we don't know its origin, I'm not sure it can not be bigger than 0.5 from time to time. And as it is supposed to be only a temporary hack, I didn't want to loose time testing it in all possible situations and take the safe way.

Yes if nobody is currently looking at it, we can push it

comment:10 by Stan, 10 years ago

Milestone: Alpha 16Alpha 17

Okay, Alway good to see new hacks :) Pushing it to A17.

comment:11 by Itms, 10 years ago

mimo, is this still valid? Do you have any update on this, could it be fixed for a17?

comment:12 by mimo, 10 years ago

Milestone: Alpha 17Alpha 18

I think wraitii wanted to have a look at it, but I guess he had no time.

comment:13 by mimo, 9 years ago

Milestone: Alpha 18Alpha 19

comment:14 by historic_bruno, 9 years ago

Milestone: Alpha 19Backlog

Moving to backlog as nobody is actively working on this and it's not a blocking issue.

comment:15 by historic_bruno, 9 years ago

Owner: wraitii removed

comment:16 by mimo, 9 years ago

Owner: set to mimo
Resolution: fixed
Status: newclosed

In 16420:

fix rounding problem in AI health, fixes #2446

comment:17 by mimo, 9 years ago

Milestone: BacklogAlpha 19
Note: See TracTickets for help on using tickets.