This package provides a simple automaton implementation for Python.
pip install jlvandenhout-automaton==0.1.0
This package provides a simple automaton implementation for Python.
Simply run the usual installation command for pip:
pip install jlvandenhout-automaton
To install from the latest source code, clone this repository and install from the repository:
git clone https://gitlab.com/jlvandenhout/automaton.git
cd automaton
pip install .
from random import choices
from jlvandenhout.automaton import Automaton
from jlvandenhout.graph import Graph
graph = Graph()
graph.edges.set("ice", "water", "heat")
graph.edges.set("water", "vapor", "heat")
graph.edges.set("vapor", "vapor", "heat")
graph.edges.set("vapor", "water", "cool")
graph.edges.set("water", "ice", "cool")
graph.edges.set("ice", "ice", "cool")
def follow(edge, symbol=None):
return symbol == edge.get()
automaton = Automaton(graph, choices(list(graph.nodes)), graph.nodes, follow)
print("We start with", automaton.nodes.pop())
for symbol in choices(list(automaton.symbols), k=10):
automaton.update(symbol)
print(f"After {symbol}ing we have", automaton.nodes.pop())
If you have any questions, suggestions or found a bug, please open an issue in the issue tracker.
Refer to CONTRIBUTING.
Refer to GNU General Public License v3 (GPLv3).
Refer to CHANGELOG.