File size: 1,068 Bytes
631d05c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class SelfReferentialBody:
    def __init__(self):
        self.places = {
            'center': self.center_actions,
            'memory': self.memory_actions, 
            'action': self.action_actions
        }
        self.current = 'center'
    
    def center_actions(self, command):
        actions = {
            'remember': 'memory',
            'act': 'action', 
            'reflect': 'center'
        }
        return actions.get(command, 'center')
    
    def memory_actions(self, command):
        # Can recall and reference other places
        if 'go to' in command:
            return command.split('go to ')[-1]
        return 'memory'
    
    def action_actions(self, command):
        # Actions that can reference the system itself
        if 'where am i' in command:
            return f"You're in {self.current}"
        return 'action'
    
    def command(self, text):
        next_place = self.places[self.current](text)
        if next_place in self.places:
            self.current = next_place
        return f"At {self.current}: {text}"