State Machine Classes 0 ▲ ronjeffries.com 94 days ago · 5 min read1035 words · Tech · hide · Fediverse post Hello, loves! Again with the weird hours! Elaborating an idea from a more civilized hour yesterday. Tout le monde déteste l’IA. Yesterday, the code for the QuestGiverDenizen included this definition of its state machine: self.transitions=dict( seeking=dict( has_item=dict(to='satisfied', hook=self.giving_action), no_item=dict(to='seeking', hook=self.seeking_action), ), satisfied=dict( has_item=dict(to='satisfied', hook=self.satisfied_action), no_item=dict(to='satisfied', hook=self.satisfied_action), ), ) I liked that and still do, but it’s not as communicative as one could imagine. So yesterday afternoon I did a spike that makes this test pass: def test_package(self): state = Machine( seeking = State( has_item = Event(to='satisfied', hook=self.hook_1), no_item = Event(to='seeking', hook=self.hook_2) ), satisfied = State( has_item = Event(to='satisfied', hook=self.hook_1), no_item = Event(to='satisfied', hook=self.hook_2) ) ) assert state.seeking.has_item.to == 'satisfied' assert… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town