diff options
| author | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-09-07 20:20:07 -0700 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth@simponic.xyz> | 2024-09-12 17:23:30 -0700 |
| commit | 8ec7f5368232d59f344e1067e1bad5e48dbcb7ae (patch) | |
| tree | 1ad2df4dc00773f2307d1525cc80ac7410ea8fba /kennel/engine/components | |
| parent | e4e31978bae7e45be57b376415a4b925ac8cbc03 (diff) | |
| download | kennel.hatecomputers.club-8ec7f5368232d59f344e1067e1bad5e48dbcb7ae.tar.gz kennel.hatecomputers.club-8ec7f5368232d59f344e1067e1bad5e48dbcb7ae.zip | |
get "cats" up there
Diffstat (limited to 'kennel/engine/components')
| -rw-r--r-- | kennel/engine/components/component.py | 1 | ||||
| -rw-r--r-- | kennel/engine/components/markov_transition_state.py | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/kennel/engine/components/component.py b/kennel/engine/components/component.py index 9f56407..90506b9 100644 --- a/kennel/engine/components/component.py +++ b/kennel/engine/components/component.py @@ -5,6 +5,7 @@ from enum import Enum class ComponentType(str, Enum): POSITION = "POSITION" CONTROLLABLE = "CONTROLLABLE" + MARKOV = "MARKOV" class Component: diff --git a/kennel/engine/components/markov_transition_state.py b/kennel/engine/components/markov_transition_state.py new file mode 100644 index 0000000..cec8223 --- /dev/null +++ b/kennel/engine/components/markov_transition_state.py @@ -0,0 +1,24 @@ +from kennel.engine.components.component import Component, ComponentType + + +class MarkovTransitionState(Component): + def __init__( + self, + state_names: dict[int, str], + initial_state_vector: list[float], + transition_matrix: list[list[float]], + ): + # TODO: Poll rate per state? + # TODO: State being an enum instead of a vector, just choose max and map + self.state_names = state_names + self.state = initial_state_vector + self.transition_matrix = transition_matrix + + super().__init__(ComponentType.MARKOV) + + def get_max_state_name(self, state_vector: list[float]): + max_val = max(state_vector) + return self.state_names[state_vector.index(max_val)] + + def to_dict(self): + return {"state": self.get_max_state_name(self.state)} |
