Esempio n. 1
0
def actr_thread(*args): #not currently used

    FLAGS(args)

    env = StarCraftEnvironment()
    env.model = actr_agent
    env.model.focus.set('no_op')

    ccm.log(env)

    env.run()
Esempio n. 2
0
    def load(self, prodFile="") -> str:

        #load all the production function names from prodFile
        self.prodFile = prodFile
        prodMod = importlib.import_module(prodFile)
        functions_list = [o for o in getmembers(prodMod) if isfunction(o[1])]

        #for each production, add name and reference to CCMAgent class
        for x in functions_list:
            name = x[0]
            log.debug(f"Adding Production: {name}")
            setattr(CCMAgent, f'{name}', x[1])

        self.agent = CCMAgent()
        self.ccm_env.agent = self.agent

        # self.load(self)

        self.perception = Perception(self.agent)
        self.working = WorkingMemory(self.agent)
        self.declarative = DeclarativeMemory(self.agent)
        self.procedural = ProceduralMemory(self.agent)
        self.motor = Motor(self.ccm_env)
        # generate a default file

        #set default options

        test_log = ccm.log(html=True)
        ccm.log_everything(self.agent, test_log)

        # This is how to dynamically load production rules

        result = "stub: load ccm actr model"
        # self.agent.goal.set('add 5 2 count:None sum:None')

        return result
import ccm

log = ccm.log()

from ccm.lib.actr import *

#####
# Python ACT-R requires an environment
# but in this case we will not be using anything in the environment
# so we 'pass' on putting things in there


class MyEnvironment(ccm.Model):
    pass


#####
# create an act-r agent


class MyAgent(ACTR):

    focus = Buffer()

    def init():
        focus.set("goal:pizza object:dough")

    def dough(focus="goal:pizza object:dough"):  # if focus buffer has this chunk then....
        print "I have made a round piece of dough"  # print
        focus.set("goal:pizza object:cheese")  # change chunk in focus buffer
Esempio n. 4
0
#################### procedure vs. retrieval ###################


import ccm      
log=ccm.log(html=False)   

from ccm.lib.actr import *  

# define the environment
class Arithmetic(ccm.Model):
    operator=ccm.Model(operator='none',visible='no')
    numbers=ccm.Model(number_left='none',number_right='none',visible='no')
    new_trial=ccm.Model(switch='yes')

import random
class MotorModule(ccm.Model):
    def reveal_operator(self):
        yield .1
        print "operator visible"
        operator=random.choice(['plus','multiply'])
        self.parent.parent.operator.operator=operator
        self.parent.parent.operator.visible='yes'
        
#     def reset_operator(self):
#         yield 0
#         self.parent.parent.operator.visible='no'
        
    def reveal_numbers(self):
    	yield .1
    	print "numbers visible"
    	nL=random.choice(['zero','one','two','three','four','five','six','seven','eight','nine'])
Esempio n. 5
0
#planning units?

#I have tried to break up task units into events that could be completed once started, even
#if interrupted... ie. turning the "rudder"- this would take a second or two, and you would complete
#even if a call came in you had to respond to...  Does this make sense?  The actions within the task
# units are meant to be brief motor or mental acts.  ie. Again, "glidescope" would consist
#of quick actions on the throttle or yoke.  Eval_cond would consist of briefly recalling wind direction/speed, and a
#scan of the runway to ensure no incursions are present.   The task unit productions below look lengthy,
#but I have added optional requests if the buffer would ever be empty- in the case of forgetting, which is what I was
#trying to do by increasing noise in the first attempt I sent you...- noise I thought represented all the baseline activity happening around the agent...


                                      #################### SGOMS ###################

import ccm      
log=ccm.log()

log=ccm.log(html=True)

from ccm.lib.actr import *


class MyEnvironment(ccm.Model):
    pass

class MyAgent(ACTR):
    Focusbuffer=Buffer()
    Contextbuffer=Buffer()
    DMbuffer=Buffer()                           #  a buffer for the declarative memory (henceforth DM)
    DM=Memory(DMbuffer)                         #  DM connected to its buffer
Esempio n. 6
0
## this model looks for an item in a location
## the salience setting on the item searched for determines how fast it is found

## this model is generalized to look for whatever is in the focus buffer
## so it can just be dumped into any model

import ccm
log = ccm.log(html=True)

from ccm.lib.actr import *


class Sock_drawer(ccm.Model):
    sock1 = ccm.Model(isa='sock',
                      location='in_drawer',
                      feature1='red_stripe',
                      salience=0.1)
    sock2 = ccm.Model(isa='sock',
                      location='in_drawer',
                      feature1='blue_stripe',
                      salience=0.9)
    spider = ccm.Model(isa='spider',
                       location='in_drawer',
                       feature1='hairy',
                       salience=0.9)


class MyAgent(ACTR):
    focus_buffer = Buffer()
    visual_buffer = Buffer()
    vision_module = SOSVision(visual_buffer, delay=0)
Esempio n. 7
0
__author__ = 'Robert'
import sys

sys.path.append('/Users/robertwest/CCMSuite')

#sys.path.append('C:/Users/Robert/Documents/Development/SGOMS/CCMSuite')

# this model does an ordered planning unit then an unordered planning unit using the same unit tasks

import ccm

log = ccm.log()

# log=ccm.log(html=True)

from ccm.lib.actr import *

# --------------- Environment ------------------


class MyEnvironment(ccm.Model):

    red_wire = ccm.Model(isa='wire', state='uncut', color='red', salience=0.99)
    blue_wire = ccm.Model(isa='wire',
                          state='uncut',
                          color='blue',
                          salience=0.99)
    green_wire = ccm.Model(isa='wire',
                           state='uncut',
                           color='green',
                           salience=0.99)
Esempio n. 8
0
#################### ham cheese production DM ask model ###################

# this builds on the production model
# two productions are added
# the first requests that the declarative memory module retrieves the condiment that the cutomer ordered
# which is stored in declarative memory
# the second production fires when this has happened


import ccm                    # all of the modeling is done within the ccm suite
log=ccm.log()                 # turn on logging (needed for some things, best to leave it on)

from ccm.lib import grid      # import gridworld to create the world
from ccm.lib.actr import *    # import act-r to create the agent

                              # create a subway sandwich bar
                              # note - do not put comments in the drawing of the map

mymap="""
#########
#       #
#       #
#########
"""

class MyCell(grid.Cell):
    def color(self):
        if self.wall: return 'black'
        else: return 'white'
    def load(self,char):      
        if char=='#': self.wall=True
Esempio n. 9
0
size = 10
trials = 10
display_time = 3

import ccm
from ccm.lib.actr import *
log = ccm.log(data=True)


class PairedExperiment(ccm.Model):
    word = ccm.Model(visible=False, x=0.5, y=0.5, font='Arial 20', type='Text')
    number = ccm.Model(visible=False,
                       x=0.5,
                       y=0.5,
                       font='Arial 20',
                       type='Number')

    def start(self):
        pairs = [('bank', '0'), ('card', '1'), ('game', '4'), ('hand', '5'),
                 ('lamb', '8'), ('mask', '9'), ('quip', '2'), ('rope', '3'),
                 ('vent', '6'), ('wall', '7')]
        items = self.random.sample(pairs, size)
        scores = []
        times = []
        for i in range(trials):
            score = 0
            time = 0
            self.random.shuffle(items)
            for w, n in items:
                self.word.text = w
                self.word.visible = True
size=10
trials=10
display_time=3

import ccm
from ccm.lib.actr import *
log=ccm.log(data=True)


class PairedExperiment(ccm.Model):
  word=ccm.Model(visible=False,x=0.5,y=0.5,font='Arial 20',type='Text')
  number=ccm.Model(visible=False,x=0.5,y=0.5,font='Arial 20',type='Number')
  
  def start(self):
      pairs=[('bank','0'),('card','1'),('dart','2'),('face','3'),
             ('game','4'),('hand','5'),('jack','6'),('king','7'),
             ('lamb','8'),('mask','9'),('neck','0'),('pipe','1'),
             ('quip','2'),('rope','3'),('sock','4'),('tent','5'),
             ('vent','6'),('wall','7'),('xray','8'),('zinc','9')]
      items=self.random.sample(pairs,size)      
      scores=[]
      times=[]
      for i in range(trials):
        score=0
        time=0
        self.random.shuffle(items)
        for w,n in items:
          self.word.text=w
          self.word.visible=True
          start=self.now()
          self.key=None
Esempio n. 11
0
#note that for this model to run, world_size and number_of_agents must be set to non 0 values,
#and the scripts must have access to the CCMsuite library (included in this repo), created by Terry Stewart & Rob West

world_size = 0
world_x_range = world_size
world_y_range = world_size
number_of_agents = 0

import sys
import os
sys.path.append(os.getcwd() + '\\CCMSuite')

import ccm
log = ccm.log(html=False)
from ccm.lib.actr import *

import random

goal_square = str(random.choice(range(world_x_range))), str(
    random.choice(range(world_y_range)))
pass  #print goal_square
agent_list = []


class Environment(
        ccm.Model
):  # items in the environment look and act like chunks - but note the syntactic differences
    prepping_world = True

    while prepping_world:
        occupied_tally = 0
Esempio n. 12
0
# CCM Suite Environment Tutorial 1
#
# The purpose of this tutorial is to make a simple environment
#  where an agent is capable of pressing either button 'A' or 'B'.
#  If they press 'A', they get one point, and if they press 'B' they
#  get 0 points.

import ccm                        # this is needed to make use of CCMSuite
log=ccm.log()                     # this sets up a log for recording data


class ForcedChoiceEnvironment(ccm.Model):
  # this is an action that can be taken by the agent in the environment
  def press(self,letter):     # 'self' refers to the thing we are currently
                              #  of defining.  In this case, the environment
    log.action=letter    # here we record what letter was pressed
    if letter=='A':
      self.reward=1      # if it was 'A', we set the reward to one.  
    else:  
      self.reward=0      # otherwise, set it to zero.


# This defines a simple agent.  We will examine this in more detail in the
#  tutorials on creating models
class SimpleModel(ccm.Model):
  def start(self):
    while True:               # repeat the following forever
      self.parent.press('A')
      yield 1                 # wait for 1 second before continuing
      
Esempio n. 13
0
# CCM Suite Environment Tutorial 1
#
# The purpose of this tutorial is to make a simple environment
#  where an agent is capable of pressing either button 'A' or 'B'.
#  If they press 'A', they get one point, and if they press 'B' they
#  get 0 points.

import ccm  # this is needed to make use of CCMSuite
log = ccm.log()  # this sets up a log for recording data


class ForcedChoiceEnvironment(ccm.Model):
    # this is an action that can be taken by the agent in the environment
    def press(self, letter):  # 'self' refers to the thing we are currently
        #  of defining.  In this case, the environment
        log.action = letter  # here we record what letter was pressed
        if letter == 'A':
            self.reward = 1  # if it was 'A', we set the reward to one.
        else:
            self.reward = 0  # otherwise, set it to zero.


# This defines a simple agent.  We will examine this in more detail in the
#  tutorials on creating models
class SimpleModel(ccm.Model):
    def start(self):
        while True:  # repeat the following forever
            self.parent.press('A')
            yield 1  # wait for 1 second before continuing