Exemple #1
0
def record_step(agent, step):

    print("Step {}:".format(step))
    print()
    print("Activations")
    output = dict(agent.output)
    del output[buffer("defaults")]
    pprint(output)
    print()
    print("WM Contents")
    pprint([cell.store for cell in agent[buffer("wm")].process.cells])
    print()
Exemple #2
0
def print_step(agent, step):

    print("Step {}:".format(step))
    print()
    print("Activations")
    output = dict(agent.output)
    del output[buffer("defaults")]
    pprint(output)
    print()
Exemple #3
0
nacs_cdb.define(chunk("PLUM"), feature("word", "/plum/"),
                feature("color", "purple"), feature("shape", "round"),
                feature("size", "small"), feature("texture", "smooth"))

### Agent Assembly ###

# Agent assembly follows a pattern similar to that shown in `flow_control.py`.

alice = Structure(name=agent("alice"),
                  assets=Assets(visual_domain=visual_domain,
                                wm_interface=wm_interface,
                                speech_interface=speech_interface))

with alice:

    stimulus = Construct(name=buffer("stimulus"), process=Stimulus())

    acs_ctrl = Construct(name=buffer("acs_ctrl"), process=Stimulus())

    # We define the working memory, by entrusting the working memory buffer
    # construct to the RegisterArray process.

    wm = Construct(name=buffer("wm"),
                   process=RegisterArray(controller=(subsystem("acs"),
                                                     terminus("wm")),
                                         sources=((subsystem("nacs"),
                                                   terminus("retrieval")), ),
                                         interface=wm_interface))

    defaults = Construct(name=buffer("defaults"),
                         process=Constants(strengths=default_strengths))
Exemple #4
0
# As in `free_association.py`, we construct a chunk database to store chunks.
# However, instead of populating the database manually, we will have the agent
# create chunks based on its interactions with audio-visual stimuli.

chunk_db = Chunks()

### Agent Assembly ###

# The assembly process should be familiar from the free association example,
# with only a couple of mild novelties.

alice = Structure(name=agent("alice"))

with alice:

    stimulus = Construct(name=buffer("stimulus"), process=Stimulus())

    nacs = Structure(name=subsystem("nacs"), assets=Assets(chunk_db=chunk_db))

    with nacs:

        # Although the entry point for the NACS are chunks, in this example we
        # start with features as there are no constructs that initially
        # activate chunks in the NACS activation cycle.

        Construct(name=features("main"),
                  process=MaxNodes(sources=[buffer("stimulus")]))

        Construct(name=flow_bt("main"),
                  process=BottomUp(source=features("main"),
                                   chunks=nacs.assets.chunk_db))
Exemple #5
0
    cdb.define(chunk("APPLE"), feature("color", "#ff0000"),
               feature("color", "#008000"), feature("tasty", True)))

cdb.define(chunk("JUICE"), feature("tasty", True), feature("state", "liquid"))

### Agent Assembly ###

# The agent assembly process is very similar to `free_association.py`, but we
# define some additional constructs and structures.

alice = Structure(name=agent("Alice"),
                  assets=Assets(gate_interface=gate_interface))

with alice:

    stimulus = Construct(name=buffer("stimulus"), process=Stimulus())

    # The acs_ctrl construct is an entry point for manually passing in commands
    # to the action-centered subsystem (ACS). Normally, the ACS would select
    # actions using action-centered knowledge based on perceptual stimuli,
    # working memory etc. For simplicity, we directly stimulate the action
    # features in the ACS to drive action selection.

    acs_ctrl = Construct(name=buffer("acs_ctrl"), process=Stimulus())

    # The gate is implemented as a buffer entrusted to a ParamSet process, as
    # mentioned earlier. To initialize the ParamSet instance, we must specify a
    # controller and pass in a gate interface.

    gate = Construct(name=buffer("gate"),
                     process=ParamSet(controller=(subsystem("acs"),
Exemple #6
0
# set maximum lag value.

# In general, `flow_in()` constructs take care of any necessary activation 
# processing within a subsystem at the start of an activation cycle. Besides 
# helping compute lagged strengths, these constructs are useful for a variety 
# of purposes that involve gating or transforming inputs to the subsystem.


alice = Structure(
    name=agent("alice")
)

with alice:

    stimulus = Construct(
        name=buffer("stimulus"), 
        process=Stimulus()
    )

    nacs = Structure(
        name=subsystem("nacs"),
    )

    with nacs:

        Construct(
            name=flow_in("lag"), 
            process=Lag(
                source=features("main"), 
                max_lag=1
            ) 
Exemple #7
0
    # cue. The NACS, on the other hand, is the Clarion subsystem that is 
    # responsible for processing non-procedural knowledge.

    # Stimulus

    # We begin by adding the stimulus component to the model. 

    # We represent the stimulus with a buffer construct, which is a top-level 
    # construct within an agent that may temporarily store data and relays 
    # activations to various subsystems. Buffers count as constructs, so we 
    # invoke the `Construct` class (as opposed to the `Structure` class as 
    # above). Aside from that, the initialization is similar to the way we 
    # created the `alice` object.

    stimulus = Construct(
        name=buffer("stimulus"), 
        process=Stimulus()
    )

    # The `process` argument defines how the structure computes its outputs. It 
    # is only available in Construct objects. 

    # Non-Action-Centered Subsystem

    # Next, we set up a realizer for the Non-Action-Centered Subsystem. The 
    # setup is similar, but we create a Structure object because subsystems may 
    # contain other constructs.  

    nacs = Structure(
        name=subsystem("nacs"),
        assets=Assets(
Exemple #8
0
# must be one-to-one.

r_map = Reinforcements(mapping={
    feature(("r", "respond")): ("respond", 0),
})

### Agent Assembly ###

learner = Structure(name=agent("learner"),
                    assets=Assets(domain=domain,
                                  interface=interface,
                                  r_map=r_map))

with learner:

    sensory = Construct(name=buffer("sensory"), process=Stimulus())

    # For this example, we will provide reinforcements directly through the use
    # of a stimulus buffer. In more sophisticated models, reinforcements may be
    # generated by the Meta-Cognitive Subsystem.

    reinforcement = Construct(name=buffer("reinforcement"), process=Stimulus())

    acs = Structure(name=subsystem("acs"))

    with acs:

        # We use a simple repeater to relay the actions selected on the
        # previous step back to the qnet.

        Construct(name=flow_in("ext_actions_lag1"),
### Agent Assembly ###

# The agent assembly process is very similar to `free_association.py`, but we 
# define some additional constructs and structures.

alice = Structure(
    name=agent("Alice"),
    assets=Assets(
        gate_interface=gate_interface
    )
)

with alice:

    stimulus = Construct(
        name=buffer("stimulus"), 
        process=Stimulus()
    )

    # The acs_ctrl construct is an entry point for manually passing in commands 
    # to the action-centered subsystem (ACS). Normally, the ACS would select 
    # actions using action-centered knowledge based on perceptual stimuli, 
    # working memory etc. For simplicity, we directly stimulate the action 
    # features in the ACS to drive action selection.

    acs_ctrl = Construct(
        name=buffer("acs_ctrl"), 
        process=Stimulus()
    )

    # The gate is implemented as a buffer entrusted to a ParamSet process, as