Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect target because of floating point arithmetic #145

Open
AttackingOrDefending opened this issue Mar 23, 2025 · 0 comments
Open

Incorrect target because of floating point arithmetic #145

AttackingOrDefending opened this issue Mar 23, 2025 · 0 comments

Comments

@AttackingOrDefending
Copy link

AttackingOrDefending commented Mar 23, 2025

In this game at frame 1524 (round 37, round frame 27) the interceptor that was at [22, 10] in the previous frame (1523) and went to [22, 11] in frame 1524 attacked the interceptor at [21, 15] instead of the one at [23, 15] because p2units was: [[22,15,113.8,"503"],[21,16,113.799995,"504"],[22,17,101.899994,"505"],[22,15,113.8,"506"]]. As you can see unit 504 had 113.799995 health while unit 506 had 113.8 health. This caused the targeting to select unit 504 because of the lower health instead of the correct unit 506 (because it was closer to an edge). The difference in health was caused by the floating point arithmetic when adding support to the units. This can be fixed in the game engine by rounding the results to some decimal places (e.g. 2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant