(self, action: ActionOrFactory)
| 285 | return random.choices(actions_or_factories, weights=class_weights, k=1)[0] |
| 286 | |
| 287 | def _can_run(self, action: ActionOrFactory) -> bool: |
| 288 | if any( |
| 289 | self._capabilities.provides(dislike) |
| 290 | for dislike in action.incompatible_with() |
| 291 | ): |
| 292 | return False |
| 293 | |
| 294 | requires = action.requires() |
| 295 | if isinstance(requires, set): |
| 296 | return all(self._capabilities.provides(req) for req in requires) |
| 297 | else: |
| 298 | for one_alternative in requires: |
| 299 | if all(self._capabilities.provides(req) for req in one_alternative): |
| 300 | return True |
| 301 | return False |
| 302 | |
| 303 | def _all_subclasses(self, cls: type[Action]) -> list[ActionOrFactory]: |
| 304 | """Return all Actions that are a subclass of the given cls.""" |
no test coverage detected