fix: prevent trivia questions repetition by using shuffled sequence#45
fix: prevent trivia questions repetition by using shuffled sequence#45pravhyn wants to merge 1 commit intoTheCodeVerseHub:mainfrom
Conversation
|
Well what??? This PR doesn't Even close the issue. that previous logic was good enough. We actually needed more questions and not This! |
youngcoder45
left a comment
There was a problem hiding this comment.
The previous logic was better more questions were needed
|
@youngcoder45 , totally adding more questions were the obvious solution, However the issue mentioned or As I understand it, They wanted to track the previously asked questions till x amount of time passes, so the same previous questions do not appear again. My solution was based on that, and I did get a confirmation on my approach to solve this problem. This is my first PR, my bad But Let me know how you want me to proceed next. Thanks for the feedback! |
The linked issue explicitly mentions the repetition of the same question being the issue. I see no reason why adding more question should be seen as a superior solution. Edit: That is not to say adding more questions is wrong. It's just that adding more questions won't solve the inherent issue of the same question being posted n-times due to pure chance. Ideally, in the future, more questions will be added, but this too is a necessary change, otherwise we'd be relying on hopes and prayers for questions not to repeat. |
HyScript7
left a comment
There was a problem hiding this comment.
There could be issues if used concurrently from multiple shards, but since the bot doesn't shard, this shouldn't be an issue anytime soon.
I'm approving these changes.
Alright I agree with you and approve too. |
youngcoder45
left a comment
There was a problem hiding this comment.
Agreed with Hyscript67
What changed?
command ?trivia doesn't use random.choice() to pick a question anymore, instead it uses a method "get_next_question()" to pick the new question
Why?
random.choice() gives the same question, because list of question is just 4 so it picks the same index few times, I've replaced the random.choice() with random.shuffle() it shuffles the question list, and then get_next_question just picks the next index to avoid repetitions until the index resets on the last question's index.
#37 trivia question problem (getting same question over and over)
How to test
Run the bot
Use the trivia command multiple times
Observe that questions do not repeat until all questions have been asked once
After all questions are used, they should reshuffle and repeat
Checklist
.env, keys)