aboutsummaryrefslogtreecommitdiff
path: root/kennel/engine/components
diff options
context:
space:
mode:
Diffstat (limited to 'kennel/engine/components')
-rw-r--r--kennel/engine/components/component.py1
-rw-r--r--kennel/engine/components/markov_transition_state.py24
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)}