MantisBT - Zandronum | ||||||||||
| View Issue Details | ||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||||
| 0001698 | Zandronum | [All Projects] Bug | public | 2014-02-09 02:06 | 2018-09-30 21:35 | |||||
| Reporter | Dusk | |||||||||
| Assigned To | Dusk | |||||||||
| Priority | high | Severity | major | Reproducibility | always | |||||
| Status | closed | Resolution | fixed | |||||||
| Platform | OS | OS Version | ||||||||
| Product Version | ||||||||||
| Target Version | 1.3 | Fixed in Version | 1.3 | |||||||
| Summary | 0001698: botscript rand() is just plain wrong | |||||||||
| 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:
| |||||||||
| Steps To Reproduce | ||||||||||
| 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(). | |||||||||
| Tags | No tags attached. | |||||||||
| Relationships |
| |||||||||
| Attached Files | ||||||||||
| Issue History | ||||||||||
| Date Modified | Username | Field | Change | |||||||
| 2014-02-09 02:06 | Dusk | New Issue | ||||||||
| 2014-02-09 02:07 | Dusk | Relationship added | related to 0001657 | |||||||
| 2014-02-09 02:07 | Dusk | Description Updated | bug_revision_view_page.php?rev_id=4478#r4478 | |||||||
| 2014-02-09 02:10 | Dusk | Additional Information Updated | bug_revision_view_page.php?rev_id=4480#r4480 | |||||||
| 2014-02-09 02:11 | Dusk | Additional Information Updated | bug_revision_view_page.php?rev_id=4481#r4481 | |||||||
| 2014-02-09 15:22 | Torr Samaho | Note Added: 0008179 | ||||||||
| 2014-03-02 22:19 | Dusk | Note Added: 0008300 | ||||||||
| 2014-03-02 22:20 | Dusk | Note Edited: 0008300 | bug_revision_view_page.php?bugnote_id=8300#r4523 | |||||||
| 2014-03-03 19:23 | Blzut3 | Note Added: 0008311 | ||||||||
| 2014-03-03 22:39 | Dusk | Note Added: 0008313 | ||||||||
| 2014-03-04 03:53 | Dusk | Note Edited: 0008313 | bug_revision_view_page.php?bugnote_id=8313#r4533 | |||||||
| 2014-03-04 04:00 | Blzut3 | Note Added: 0008315 | ||||||||
| 2014-05-18 12:47 | Dusk | Assigned To | => Dusk | |||||||
| 2014-05-18 12:47 | Dusk | Status | new => needs review | |||||||
| 2014-06-01 15:15 | Torr Samaho | Note Added: 0008827 | ||||||||
| 2014-06-01 15:15 | Torr Samaho | Status | needs review => needs testing | |||||||
| 2014-10-05 22:20 | Dusk | Fixed in Version | => 1.3 | |||||||
| 2014-10-05 22:22 | Dusk | Note Added: 0010345 | ||||||||
| 2014-10-05 22:22 | Dusk | Status | needs testing => resolved | |||||||
| 2014-10-05 22:22 | Dusk | Resolution | open => fixed | |||||||
| 2018-09-30 21:35 | Blzut3 | Status | resolved => closed | |||||||
| Notes | |||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||
|
|
|||||
|
|
||||