09-04-2018, 01:28 AM
(This post was last modified: 09-04-2018, 02:40 AM by sirpipthegreat.)
I could probably write something using [random.choice] in python easier than in QM, but wanted to know if there's a way to return values from a weighted dictionary without reinventing the wheel. I'm passing the results back to a QM dialog, so i'd rather not have to package in python dependencies on work computers if i could avoid it.
Ideally, the array would have two dimensions, result and weight, but be dynamic so that updates could be made to the dictionary without recompiling in QM.
Percents would work, but it would also be preferable if it didn't need to add to 100%
;; dictionary fruit.txt would have several arrays similar to this:
{
"apple", 9
"pear", 1
"banana", 10
"orange", 20
}
When ran on this set, apple should be the result 9/40 times, pear 1/40, banana 10/40, and orange 20/40.
If it is going to be a nightmare to do in QM, i will use python and deal with it..
All of the users here are brilliant and way more experienced than i am, so i thought i would ask if there's a simple way to do this (before i pull out any more hair).
Thank you all.
Ideally, the array would have two dimensions, result and weight, but be dynamic so that updates could be made to the dictionary without recompiling in QM.
Percents would work, but it would also be preferable if it didn't need to add to 100%
;; dictionary fruit.txt would have several arrays similar to this:
{
"apple", 9
"pear", 1
"banana", 10
"orange", 20
}
When ran on this set, apple should be the result 9/40 times, pear 1/40, banana 10/40, and orange 20/40.
If it is going to be a nightmare to do in QM, i will use python and deal with it..
All of the users here are brilliant and way more experienced than i am, so i thought i would ask if there's a simple way to do this (before i pull out any more hair).
Thank you all.