Exemplo n.º 1
0
def actr_thread2(*args): #not currently used

    FLAGS(args)

    env = MatchEnvironment()
    env.model = actr_model
    env.model.goal.set('attend')

    ccm.display(env)

    #actr_agent = ActrAgent()
    #actrEnv = StarCraftEnvironment()
    #actrEnv.agent = actr_agent

    #ccm.log_everything(env)

    env.run()
Exemplo n.º 2
0
from ccm.lib.actr import *


# Define the ACT-R Model
class Model(ACTR):
    goal = Buffer()
    visual = Buffer()
    vision = SOSVision(visual)

    def findUnattendedLetter(goal='attend', vision='busy:False'):
        vision.request('isa:letter')
        goal.set('attend')

    def encodeLetter(goal='attend', visual='isa:letter text:?letter'):
        goal.set('respond ?letter')

    def respond(goal='respond ?letter'):
        self.parent.press(letter)
        visual.clear()
        goal.set('attend')


env = MatchEnvironment()
env.model = Model()
env.model.goal.set('attend')

ccm.display(env)

env.run()
        self.action=None
        self.busy=False
        
        


class MyAgent(ACTR):
    focus=Buffer()
    body=grid.Body()
    motor=MotorModule()

    def init():
        focus.set('wander')

    def wandering_forward(focus='wander',motor='busy:False'):
        motor.go_forward()

    def wandering_left(focus='wander',motor='busy:False'):
        motor.go_left()

    def wandering_right(focus='wander',motor='busy:False'):
        motor.go_right()
            

world=grid.World(MyCell,map=mymap)
agent=MyAgent()
world.add(agent,x=5,y=3)
ccm.display(world)
ccm.log_everything(agent)
world.run()
Exemplo n.º 4
0
            self.letter.visible=True
            self.target=self.letter.text
        
from ccm.lib.actr import *
# Define the ACT-R Model    
class Model(ACTR):
  goal=Buffer()
  visual=Buffer()
  vision=SOSVision(visual)
  
  def findUnattendedLetter(goal='attend',vision='busy:False'):
    vision.request('isa:letter')
    goal.set('attend')
    
  def encodeLetter(goal='attend',visual='isa:letter text:?letter'):
    goal.set('respond ?letter')
    
  def respond(goal='respond ?letter'):
    self.parent.press(letter)
    visual.clear()
    goal.set('attend')


env=MatchEnvironment()
env.model=Model()
env.model.goal.set('attend')

ccm.display(env)
    
env.run()
Exemplo n.º 5
0
class ForcedChoiceEnvironment(ccm.Model):
    trials = 0
    score = 0
    button1 = Button(letter='A',
                     reward=1,
                     x=0.2,
                     y=100,
                     text='A',
                     color='blue')
    button2 = Button(letter='B', reward=0, x=0.8, y=100, text='B', color='red')
    display = Reward(reward=0, x=0.5, y=0.5, visible=False)


import random


class SimpleModel(ccm.Model):
    def start(self):
        while True:
            choice = random.choice(['A', 'B'])
            if choice == 'A': self.parent.button1.press()
            if choice == 'B': self.parent.button2.press()
            yield 1


model = SimpleModel()
env = ForcedChoiceEnvironment()
env.agent = model
display = ccm.display(env)
env.run()
        if self.parent.trials==200: self.stop()

class Reward(ccm.Model):
    def text(self):
        return self.reward
      

class ForcedChoiceEnvironment(ccm.Model):
  trials=0
  score=0
  button1=Button(letter='A',reward=1,x=0.2,y=100,text='A',color='blue')
  button2=Button(letter='B',reward=0,x=0.8,y=100,text='B',color='red')
  display=Reward(reward=0,x=0.5,y=0.5,visible=False)

          

import random
class SimpleModel(ccm.Model):
  def start(self):
    while True:
      choice=random.choice(['A','B'])
      if choice=='A': self.parent.button1.press()
      if choice=='B': self.parent.button2.press()
      yield 1
           
model=SimpleModel()
env=ForcedChoiceEnvironment()
env.agent=model
display=ccm.display(env)
env.run()