Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class C32:
- def __init__(self):
- self.state = 'A'
- self.transitions = {
- 'A': {'paint': ('B', 0)},
- 'B': {
- 'paint': ('F', 2),
- 'join': ('C', 1),
- },
- 'C': {
- 'paint': ('A', 4),
- 'join': ('D', 3),
- },
- 'D': {
- 'roam': ('D', 6),
- 'join': ('E', 5)
- },
- 'E': {
- 'roam': ('F', 7),
- 'paint': ('E', 8)
- },
- 'F': {}
- }
- def roam(self):
- return self.goto_next('roam')
- def paint(self):
- return self.goto_next('paint')
- def join(self):
- return self.goto_next('join')
- def goto_next(self, command):
- transition = self.transitions[self.state].get(command, None)
- if transition is not None:
- self.state = transition[0]
- return transition[1]
- else:
- return None
Advertisement
Add Comment
Please, Sign In to add comment