diff --git a/Example1Hello.py b/Example1Hello.py new file mode 100644 index 0000000..9d86ab8 --- /dev/null +++ b/Example1Hello.py @@ -0,0 +1,42 @@ +#!pip install python_actr #uncomment this if needed +from python_actr import * +class MyEnv(Model): + pass +class MyAgent(ACTR): + goal = Buffer() # Creating the goal buffer for the agent + def init(): # this rule fires when the agent is instantiated. + goal.set("helloworld") # set goal buffer to direct program flow + def bread_bottom(goal="helloworld"): # if goal="helloworld" , fire rule + print ("Hello World!") + goal.set("stop") # set goal buffer to direct program flow + #def stop_production(goal="stop"): + #self.stop() # stop the agent + +celscilist = { +'dd':{'x':{'followers': 400}}, +'jp':{'x':{'followers': 300}}, +'sh':{'x':{'followers': 200}}, +'gs':{'x':{'followers': 100}} +} + +class celsci(): + + def fame(x): + y="low" + if x>300: + y= 'high' + return y + +def checkfame(x): + person = celsci.fame(celscilist[x]['x']['followers']) + return person + +for person in celscilist: + #dh=ic(person,checkfame(person)) + print(person,checkfame(person)) + +tim = MyAgent() +subway=MyEnv() +subway.agent=tim +log_everything(subway) +subway.run() diff --git a/python_actr/__init__.py b/python_actr/__init__.py index 2da751b..fc65d6f 100644 --- a/python_actr/__init__.py +++ b/python_actr/__init__.py @@ -5,3 +5,4 @@ from .display import display from .actr import * from . import version +from .csdh import Celsci diff --git a/python_actr/csdh.py b/python_actr/csdh.py new file mode 100644 index 0000000..d18b237 --- /dev/null +++ b/python_actr/csdh.py @@ -0,0 +1,42 @@ +##!pip install python_actr #uncomment this if needed +##from python_actr import * +#class MyEnv(Model): +# pass +#class MyAgent(ACTR): +# goal = Buffer() # Creating the goal buffer for the agent +# def init(): # this rule fires when the agent is instantiated. +# goal.set("helloworld") # set goal buffer to direct program flow +# def bread_bottom(goal="helloworld"): # if goal="helloworld" , fire rule +# print ("Hello World!") +# goal.set("stop") # set goal buffer to direct program flow +# #def stop_production(goal="stop"): +# #self.stop() # stop the agent + + +class Celsci: + celscilist = { + 'dd':{'x':{'followers': 400}}, + 'jp':{'x':{'followers': 300}}, + 'sh':{'x':{'followers': 200}}, + 'gs':{'x':{'followers': 100}} + } + asname="aso" + def fame(x): + y="low" + if x>300: + y= 'high' + return y + +def checkfame(x): + person = Celsci.fame(Celsci.celscilist[x]['x']['followers']) + return person + +for person in Celsci.celscilist: + #dh=ic(person,checkfame(person)) + print(person,checkfame(person)) + +#tim = MyAgent() +#subway=MyEnv() +#subway.agent=tim +#log_everything(subway) +#subway.run() diff --git a/python_actr/model.py b/python_actr/model.py index f45f80c..a573eb5 100644 --- a/python_actr/model.py +++ b/python_actr/model.py @@ -40,15 +40,34 @@ def log_everything(model,log=None): if isinstance(v,Model) and v.parent is model: log_everything(v,getattr(log,k)) +celscilist = { +'dd':{'x':{'followers': 700}}, +'jp':{'x':{'followers': 300}}, +'sh':{'x':{'followers': 200}}, +'gs':{'x':{'followers': 100}} +} - +class Celsci: + ax11="ax22" + def fame(x): + y="low" + if x>300: + y= 'high' + return y + +def checkfame(x): + person = Celsci.fame(celscilist[x]['x']['followers']) + return person + +for person in celscilist: + #dh=ic(person,checkfame(person)) + print(person,checkfame(person)) + class Model: __converted=False _convert_methods=True _auto_run_start=True - name='top' - - + name='top4' def __init__(self,log=None,**keys): #print("this happens") @@ -56,7 +75,10 @@ def __init__(self,log=None,**keys): self.__init_log=log for k,v in list(keys.items()): setattr(self,k,v) + + + #getitem added by sterling def __getitem__(self,item): return getattr(self,item)