Skip to content

AddingExample1 #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Example1Hello.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions python_actr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from .display import display
from .actr import *
from . import version
from .csdh import Celsci
42 changes: 42 additions & 0 deletions python_actr/csdh.py
Original file line number Diff line number Diff line change
@@ -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()
30 changes: 26 additions & 4 deletions python_actr/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,45 @@ 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")
#print(self,"Model A1")#sterling
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)
Expand Down