Anonymous | Login | Signup for a new account | 2025-06-20 16:31 UTC | ![]() |
My View | View Issues | Change Log | Roadmap | All Projects Issue Support Ranking | Rules | My Account |
View Revisions: Issue #1698 | [ Back to Issue ] | ||
Summary | 0001698: botscript rand() is just plain wrong | ||
Revision | 2014-02-09 02:06 by Dusk | ||
Description |
first of all, this causes lMax not to be a possible return value. this is in direct clash with ACS's random() which is confusing. secondly, this causes bias. if suppose rand is called with, say args 5 and 9, this would first get seed.Random() % 9, which gets a random value between 0 and 8 inclusive. the while loop then offsets the values. possible outcomes: 0 (less than 5): -> 4 -> 8 1 (less than 5): -> 5 2 (less than 5): -> 6 3 (less than 5): -> 7 4 (less than 5): -> 8 5 6 7 8 overall probability: - 5: 2 / 9 = 22.2% - 6: 2 / 9 = 22.2% - 7: 2 / 9 = 22.2% - 8: 3 / 9 = 33.3% - 9: 0 / 9 = 0% notice how it favors the value 8. suggested change:
|
||
Revision | 2014-02-09 02:07 by Dusk | ||
Description | botcommands.cpp:867:
first of all, this causes lMax not to be a possible return value. this is in direct clash with ACS's random() which is confusing. secondly, this causes bias. if suppose rand is called with, say args 5 and 9, this would first get seed.Random() % 9, which gets a random value between 0 and 8 inclusive. the while loop then offsets the values. possible outcomes: 0 (less than 5): -> 4 -> 8 1 (less than 5): -> 5 2 (less than 5): -> 6 3 (less than 5): -> 7 4 (less than 5): -> 8 5 6 7 8 overall probability: - 5: 2 / 9 = 22.2% - 6: 2 / 9 = 22.2% - 7: 2 / 9 = 22.2% - 8: 3 / 9 = 33.3% - 9: 0 / 9 = 0% notice how it favors the value 8. suggested change:
|
||
Revision | 2014-02-09 02:06 by Dusk | ||
Additional Information | |||
Revision | 2014-02-09 02:10 by Dusk | ||
Additional Information | If we absolutely have to keep the original behavior for backwards compatibility, I suggest we introduce a new random() for this behavior. I can make botc use this one for random() and not use the current, broken rand(). | ||
Revision | 2014-02-09 02:11 by Dusk | ||
Additional Information | if we absolutely have to keep the original behavior for backwards compatibility, I suggest we introduce a new random() for this behavior. I can make botc use this one for random() and not use the current, broken rand(). |
Copyright © 2000 - 2025 MantisBT Team |