Kruhlmann / gatekeeper

Fight club CAPTCHA bot
GNU General Public License v3.0
1 stars 4 forks source link

Hit Chance Rounding Bug #103

Closed mayhem-shazzrah closed 4 years ago

mayhem-shazzrah commented 4 years ago

Hit/Miss Chance is incorrectly rounded up to the nearest integer instead of preserving one digit of accuracy. More specifically https://github.com/Kruhlmann/gatekeeper/blob/f79eeb11f7b029730f9f50c91bb9781314037112/src/captchas.ts#L158 should read:

answer = Math.ceil((miss_chance + miss_penalty) * 10) / 10;
Kruhlmann commented 4 years ago

This is expected behavior. A lot of users were confused about answers like 8.6, when you can only get hit % in integers from gear, hence the change.

Kruhlmann commented 4 years ago

This is documented in this commit c517fabbe94a7943fca7097a367229ddfbf960f4

https://github.com/Kruhlmann/gatekeeper/blob/c517fabbe94a7943fca7097a367229ddfbf960f4/src/captchas.ts#L158-L161

mayhem-shazzrah commented 4 years ago

This is expected behavior. A lot of users were confused about answers like 8.6, when you can only get hit % in integers from gear, hence the change.

Ok, but can we then update the message from hit cap (rounded up to nearest 1/10th) to hit cap (rounded up to nearest integer)? (along with the example). Otherwise you will generate misleading captchas for odd-level mobs, like this one, where following the literal instructions and formulas don't give the correct answer: misleading-captcha

mayhem-shazzrah commented 4 years ago

btw if you give me the permissions i can make a PR for this and maybe help with other stuff you might need in the future.

mayhem-shazzrah commented 4 years ago

otherwise, here is a patch file you can apply on top of the latest master

diff --git a/src/captchas.ts b/src/captchas.ts
index e17bec3..d211534 100644
--- a/src/captchas.ts
+++ b/src/captchas.ts
@@ -158,8 +158,8 @@ function calc_mitigation(
         answer = Math.ceil(miss_chance + miss_penalty);
         query = `the hit from gear required to reach your **${
             yellow_hits ? "yellow" : "white"
-        }** hit cap (rounded up to nearest 1/10th)?`;
-        example = "13.1";
+        }** hit cap (rounded up to nearest integer)?`;
+        example = "13";
     }

     return { answer, query, example };
Kruhlmann commented 4 years ago

You should have permissions to make a PR, just create a fork and apply your changes.