Create app0
Browse files
app0
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from python_actr import * ## Imports the code you need to run Python ACT-R
|
| 2 |
+
import transformers
|
| 3 |
+
from transformers.utils import logging
|
| 4 |
+
#logger=HTMLLogger(name="Test App", html_filename="log.html", console_log=False)
|
| 5 |
+
|
| 6 |
+
logging.set_verbosity_info()
|
| 7 |
+
logger = logging.get_logger("transformers")
|
| 8 |
+
|
| 9 |
+
logger.info('This is info')
|
| 10 |
+
|
| 11 |
+
# Using the code above, if python_actr is not installed, it first install python_actr
|
| 12 |
+
# then imports its modules: from python_actr import *
|
| 13 |
+
# so no needs to import the following modules one by one, but you can use them instead
|
| 14 |
+
# by uncommenting one by one, when needed, instead of importing everything at once:
|
| 15 |
+
#import python_actr
|
| 16 |
+
#from python_actr import log
|
| 17 |
+
#from python_actr import ACTR
|
| 18 |
+
#from python_actr import Model
|
| 19 |
+
#from python_actr import Buffer
|
| 20 |
+
#from python_actr import Memory
|
| 21 |
+
#from python_actr import DMSpreading
|
| 22 |
+
#from python_actr import log_everything
|
| 23 |
+
class MyEnv(Model):
|
| 24 |
+
pass
|
| 25 |
+
class MyAgent(ACTR):
|
| 26 |
+
production_time = 0.05
|
| 27 |
+
production_sd = 0.01
|
| 28 |
+
production_threshold = -20
|
| 29 |
+
|
| 30 |
+
goal = Buffer() # Creating the goal buffer for the agent
|
| 31 |
+
|
| 32 |
+
def init(): # this rule fires when the agent is instantiated.
|
| 33 |
+
goal.set("sandwich bread") # set goal buffer to direct program flow
|
| 34 |
+
def bread_bottom(goal="sandwich bread"): # if goal="sandwich bread" , fire rule
|
| 35 |
+
print ("I have a piece of bread")
|
| 36 |
+
goal.set("stop") # set goal buffer to direct program flow
|
| 37 |
+
def stop_production(goal="stop"):
|
| 38 |
+
self.stop() # stop the agent
|
| 39 |
+
logger.debug('This is debug')
|
| 40 |
+
logger.warning("This is <hl>warning</hl>")
|
| 41 |
+
logger.error('This is an <hl>error</hl>')
|
| 42 |
+
#logger.table('Add html table:<table><tr><th>...</th></tr></table>')
|
| 43 |
+
|
| 44 |
+
tim = MyAgent()
|
| 45 |
+
subway=MyEnv()
|
| 46 |
+
subway.agent=tim
|
| 47 |
+
#log_everything(subway)
|
| 48 |
+
subway.run()
|