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

Stun Duration Comparison - Divide by 0 error in sim.py #31

Open
CameronNDS opened this issue Mar 29, 2024 · 2 comments
Open

Stun Duration Comparison - Divide by 0 error in sim.py #31

CameronNDS opened this issue Mar 29, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@CameronNDS
Copy link

Issue

When running a Borge comparison if the stuntime on either build is zero (due to not taking any impeccable impacts) the comparison code errors out with ZeroDivisionError.

This is due to these lines:
https://github.com/bhnn/hunter-sim/blob/main/hunter-sim/sim.py#L206
https://github.com/bhnn/hunter-sim/blob/main/hunter-sim/sim.py#L210

Normally zeros are caught by the if statements checking for zeros but 'stun_duration_inflicted' is a datetime.timedelta object. These don't compare to integers as expected so datetime.timedelta(0) != 0 returns true causing the code to still run dict2[k][vk] / dict1[k][vk] giving the ZeroDivisionError.

Suggested Fix

I only dug into the code to check this one error so main devs might have better ideas. But my suggestion is to add an additional if statement that catches 'stun_duration_inflicted' and runs it through it's own copy of the same comparison code using dict1[k][vk] != datetime.timedelta(0) & dict2[k][vk] != datetime.timedelta(0) respectively. This should compare as expected.

@bhnn
Copy link
Owner

bhnn commented Apr 8, 2024

Hey!

Did this issue come up before or after the merge 88fef60 2 weeks ago?

@CameronNDS
Copy link
Author

After. My copy of sim.py has those changes in it.

@bhnn bhnn self-assigned this Apr 9, 2024
@bhnn bhnn added the bug Something isn't working label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants