Use random.choices
when selecting a task instead of random.choice
#2651
Labels
random.choices
when selecting a task instead of random.choice
#2651
Prerequisites
Description
According to current implementation/documentation, if weights are given to tasks, tasks are stored in the list duplicated by the amount given as weight, and then the task is selected from the list by using Python's
random.choice
.This, however, has two shortcomings:
It should be fairly easy to rewrite the
gen_tasks_from_base_classes
function and how it's output is handled inTaskSet
class to store the weights separately and pass them together with the list of tasks torandom.choices
ingen_next_task
.This will allow to store arbitrarily large weights without duplicating tasks in integer or float as well as potentially enable the functionality to modify task weights at runtime by modifying the list storing the weights.
I could try to implement this with a PR if this change is desired.
The text was updated successfully, but these errors were encountered: