question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mismatch between planet explosion code, comments, and documentation

See original GitHub issue

docs

When a planet dies, it explodes, dealing damage to any ships or planets within 10 units of the planet surface. The damage scales linearly with distance from the surface, beginning at 255 damage when adjacent to the planet and ending at 51 damage if 5 units away.

code

Logic is here: https://github.com/HaliteChallenge/Halite-II/blob/11b7d6c1abc588d0de250b854d9d47963077b786/environment/core/Halite.cpp#L71-L84

Where distance is center of planet to closest edge of the target (ship or other planet), distance_from_crust is the distance from planet crust to the closest edge of the target, and max_distance is the higher of the docking radius constant (4) or the planet’s radius.

Only ships within max_distance are considered for this method, so any damage scaling beyond the planet radius (or docking distance) is ignored.

I think the damage is closer to this (but could be wrong, can somebody verify?)

radius distance damage
2 0 1275
2 2 1211.25
2 4 1147.5
4 0 1275
4 4 1147.5
8 0 1275
8 4 1211.25
8 8 1147.5

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Billiamcommented, Nov 9, 2017

I think this new logic is backwards:

const auto damage = min_damage + (distance_from_crust / max_distance) * (max_damage - min_damage);

At a close distance (1) to a planet with a radius of 4

auto_damage = 127.5 + (1 / 4) * (1275 - 127.5)  # 414.375 damage

At the maximum distance

auto_damage = 127.5 + (4 / 4) * (1275 - 127.5) # 1275.0 damage

I think you’d want

const auto damage = min_damage + (1 - distance_from_crust / max_distance) * (max_damage - min_damage);
0reactions
lidavidmcommented, Nov 9, 2017

@Billiam good catch, my mistake.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deep Code Comment Generation - Xin Xia
Unfortunately, due to tight project schedule and other reasons, code comments are often mismatched, missing or outdated in many projects.
Read more >
Guidelines for Diagnostics - GNU Compiler Collection Internals 13.0 ...
Many diagnostics relate to a mismatch between two different places in the user's source code. Examples include: a type mismatch, where the type...
Read more >
Avoiding Errors with Good Comments - Dummies.com
Proper documentation helps people to understand your code better and avoid mistakes before they happen (or even before someone can think of a...
Read more >
Engineering Ethics Case Study: The Challenger Disaster
This course provides instruction in engineering ethics through a case study of the Space Shuttle. Challenger disaster. The course begins by presenting the ......
Read more >
Error Code Mismatches Between Documentation and the Real ...
comments, then check these against actual code behavior using. backtracking path exploration. ... While our work focuses on finding mismatches between code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found