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

Subscriber wait time multiplier and !weightednext #39

Merged
merged 36 commits into from
Oct 25, 2022
Merged

Subscriber wait time multiplier and !weightednext #39

merged 36 commits into from
Oct 25, 2022

Conversation

liquidnya
Copy link

@liquidnya liquidnya commented Sep 24, 2022

This PR adds:

  • A subscriber multiplier for wait time. E.g. set to 1.2 subscribers will gain a wait time of 6 minutes for every 5 minutes of waiting.
  • A !weightednext command/order option. This will pick the use with the highest wait time.
  • !list will now list levels by weighted chance. (only if weightednext is present in the levels order)
  • !position will now show your weighted position. (only if weightednext is present in the levels order)
  • !odds will now show your weight multiplier. (only if it is bigger than 1.0)
  • !odds and !list will show <0.1% if someones chance is more than 0% but would have been rounded to 0.0% and will show >99.9% if someones chance is less than 100% but would have been rounded to 100.0%.
  • !weightedsubnext and !weightedsubrandom variants of !weightednext and !weightedrandom respectively, but only picks subscribers.

This PR also merges #27, #31, and #35 and fixes #6, and fixes #9.

Configuration:

  • Added subscriberWeightMultiplier to the configuration which can be set to a floating point number bigger than or equal to 1.0. This will multiply the weight for the weighted random chance for subscribers.

Bug fixes:

  • Fixed a bug where if someone gets picked by !weightedrandom the removal of their wait time / weighted random chance was not persisted and only saved to the ./data/queue.json file on the next save.

Implementation details:

  • The version of the save file will be bumped up to 2.1 and will still be downwards compatible with version 2.0.
    • waitTime will still be the time users waited in minutes. This value is not influenced by the subscriber multiplier
    • Introduction of weightMin which stores the weight of the weighted random chance in minutes. This value will be initialized with the waitTime but is influenced by the subscriber multiplier.
    • Introduction of weightMsec which stores the weight of the weighted random chance in milliseconds. This is needed because e.g. if the subscriber multiplier is 1.2 then this would add 1 minute and 12000 milliseconds. This value will always be between 0 (inclusive) and 59999 (inclusive).
  • The weight is weightMin + weightMsec rounded to the nearest minute. E.g. 1 minute and 12000 milliseconds will give a weight of 1, and 9 minutes and 36000 milliseconds will give a weight of 10.
  • If someone has the same maximum random chance then !weightednext will pick the user who is nearer to the top of the queue.
  • The versions of devDependencies have been upgraded to newer versions. Run npm install before running npm test, but there is no need to use npm install for running the queue itself if it was upgraded from a previous version.

@liquidnya
Copy link
Author

I would like to get some feedback about the message that is displayed when a !weightednext level is chosen.
Currently it will say something like:
(weightednext) Now playing a ROMhack submitted by liquidnya with the highest wait time of 14.3%.

@liquidnya
Copy link
Author

I think it would be a good idea to add the subscriber multiplier to the end of the response of the !odds command.
This should be done only for subscribers and only if the multiplier is greater than 1.0.

@ToransuShoujo ToransuShoujo merged commit 3e220fb into ToransuShoujo:master Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.0% odds !weightednext and subscriber variants of the weighted commands
2 participants