Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Genesis 3

Status
Not open for further replies.

lornalod

Technical User
Jan 21, 2024
3
0
0
US
How to write a code for Adam and eve in the Garden
Serpent comes to tell them it is ok to eat the fruit.
They Eat the fruit, they realize they sin.
Then curse happens
 
Anyways, because I was bored and curious about nested state machines using Transitions:

<<Deleted>>

Not fully functional, but I've wasted enough time....

 
And after a bit more study about Transitions Nested and Parallel states:

Python:
from transitions.extensions.factory import HierarchicalGraphMachine
import graphviz
from IPython import display

Code:
Fruit = {'name': 'Fruit', 'states': ['forbidden', 'tasty'], 'transitions': [['god_says', 'tasty', 'forbidden'],['serpent_says', 'forbidden', 'tasty']], 'initial': 'forbidden'}
Sinned = {'name': 'Sinned', 'states': ['True', 'False'], 'transitions':[['eat_fruit', 'False', 'True'],['repent', 'True', 'False']], 'initial': 'False'}
GodIs = {'name': 'GodIs', 'states': ['Benevolent', 'Vengeful'],'transitions': [['eat_fruit', 'Benevolent', 'Vengeful'],['forgiven', 'Vengeful', 'Benevolent']],  'initial': 'Benevolent'}

Beliefs = {'name': 'Beliefs', 'parallel': [Fruit, Sinned, GodIs]}

Ate_Fruit = {'name': 'Ate', 'states': ['True', 'False'], 'transitions': [['eat_fruit', 'False', 'True'],['vomit', 'True', 'True']], 'initial': 'False'}

states = [{'name': 'Self', 'parallel': [Beliefs, Ate_Fruit]}]

Eve = HierarchicalGraphMachine(states=states, initial=['Self_Beliefs_GodIs_Benevolent', 'Self_Beliefs_Sinned_False', 'Self_Beliefs_Fruit_forbidden' ,'Self_Ate_False'])

beginning_prqhqp.png


Code:
Eve.serpent_says()

serpent_g1rzck.png


Code:
Eve.eat_fruit()

end_yzenjk.png
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top