snoonetIRC / CloudBot

CloudBot - The simple, fast, expandable, open-source Python IRC Bot!
GNU General Public License v3.0
67 stars 52 forks source link

Refactored n_rolls function in the gaming plugin to be more readable #389

Closed leonthemisfit closed 5 years ago

leonthemisfit commented 5 years ago

The original code had several issues that have been addressed in this commit. First, the function is never called from the coin function so having this logic there is unnecessary and adding clutter. Second, calculating the entire standard deviation as a single formula is confusing and extremely hard to read and debug, so this was split onto multiple lines. Finally, the method of calculating the variance for use with the standard deviation was a longer and more roundabout way of finding it. This was replaced with an equivalent but shorter and more concise formula.

On branch gonzobot+gaming Changes to be committed: modified: plugins/gaming.py