samedi 12 mars 2022

How do I make an uneven probability to choose one of so many functions?

I'm writing an "AI" (more like a chatbot), and I have a bunch of different functions it can do. It can send a wikipedia article, post a meme, ask a question, etc. I want each of these possible outcomes to have a different weighted probability (IE, 30% chance of it posting a meme, only 10% for it posting a meme, etc) the obvious way to do this is to get a random float and just check if the value is less than a given one. The problem with this is I' m going to be adding more functions and I want to tweak the probability of each outcome as I go so it feels better. What is the best way to choose between these functions in an easily-choosable way?




Aucun commentaire:

Enregistrer un commentaire