actr

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package actr implements our internal, parsed version of the amod file which is passed to a Framework to generate their code.

Index

Constants

This section is empty.

Variables

View Source
var ACTRLoggingLevels = []string{
	"min",
	"info",
	"detail",
}

Functions

func IsInternalChunkName

func IsInternalChunkName(name string) bool

func ValidLogLevel

func ValidLogLevel(e string) bool

Types

type ACTRLogLevel

type ACTRLogLevel string

type Chunk

type Chunk struct {
	Name      string
	SlotNames []string
	NumSlots  int

	AMODLineNumber int // line number in the amod file of the this chunk declaration
}

func (Chunk) HasSlot

func (chunk Chunk) HasSlot(slot string) bool

HasSlot checks if the slot name exists on this chunk.

func (Chunk) IsInternal

func (c Chunk) IsInternal() bool

func (Chunk) SlotIndex added in v0.7.0

func (chunk Chunk) SlotIndex(slot string) int

SlotIndex returns the slot index (indexed from 1) of the slot name or -1 if not found.

func (Chunk) SlotName added in v0.2.0

func (c Chunk) SlotName(index int) (str string)

SlotName returns the name of the slot given the index.

type ClearStatement

type ClearStatement struct {
	BufferNames []string
}

ClearStatement clears a list of buffers.

type Comparison added in v0.8.0

type Comparison int
const (
	Equal Comparison = iota
	NotEqual
)

func (Comparison) String added in v0.8.0

func (c Comparison) String() string

type Constraint added in v0.8.0

type Constraint struct {
	LHS        *string
	Comparison Comparison
	RHS        *Value
}

func (Constraint) String added in v0.8.0

func (c Constraint) String() string

type Initializer

type Initializer struct {
	Module         modules.ModuleInterface
	Buffer         buffer.BufferInterface
	Pattern        *Pattern
	AMODLineNumber int // line number in the amod file of this initialization
}

type Match

type Match struct {
	Buffer  buffer.BufferInterface
	Pattern *Pattern
}

type Model

type Model struct {
	Name        string
	Description string
	Authors     []string
	Examples    []*Pattern

	Modules    []modules.ModuleInterface
	Memory     *modules.DeclarativeMemory // memory is always present
	Goal       *modules.Goal              // goal is always present
	Procedural *modules.Procedural        // procedural is always present
	Chunks     []*Chunk

	Initializers []*Initializer
	Productions  []*Production
	// contains filtered or unexported fields
}

Model represents a basic ACT-R model. This is used as input to a Framework where it can be run or output to a file. (This is incomplete w.r.t. all of ACT-R's capabilities.)

func (Model) BufferNames added in v0.6.0

func (model Model) BufferNames() (list []string)

BufferNames returns a slice of valid buffers.

func (*Model) CreateExtraBuffers added in v0.9.0

func (model *Model) CreateExtraBuffers() *modules.ExtraBuffers

CreateExtraBuffers creates the "extra_buffers" module and adds it to the list.

func (*Model) CreateImaginal

func (model *Model) CreateImaginal() *modules.Imaginal

CreateImaginal creates the imaginal module and adds it to the list.

func (Model) HasPrintStatement

func (model Model) HasPrintStatement() bool

HasPrintStatement checks if this model uses the print statement. This is used to include extra code to handle printing in some frameworks.

func (Model) ImaginalModule added in v0.7.0

func (model Model) ImaginalModule() *modules.Imaginal

ImaginalModule gets the imaginal module (or returns nil if it does not exist).

func (*Model) Initialize

func (model *Model) Initialize()

func (Model) LookupBuffer

func (model Model) LookupBuffer(bufferName string) buffer.BufferInterface

LookupBuffer looks up the named buffer in the model and returns it (or nil if it does not exist).

func (Model) LookupChunk

func (model Model) LookupChunk(chunkName string) *Chunk

LookupChunk looks up the named chunk in the model and returns it (or nil if it does not exist).

func (Model) LookupInitializer added in v0.6.0

func (model Model) LookupInitializer(buffer string) *Initializer

LookupInitializer returns an initializer or nil if the buffer does not have one.

func (Model) LookupModule added in v0.2.0

func (model Model) LookupModule(moduleName string) modules.ModuleInterface

LookupModule looks up the named module in the model and returns it (or nil if it does not exist).

func (*Model) SetParam added in v0.7.0

func (model *Model) SetParam(param *params.Param) (err error)

type Pattern

type Pattern struct {
	Chunk *Chunk
	Slots []*PatternSlot
}

func (*Pattern) AddSlot

func (p *Pattern) AddSlot(slot *PatternSlot)

func (Pattern) LookupVariable

func (p Pattern) LookupVariable(varName string) *PatternVar

func (Pattern) String

func (p Pattern) String() (str string)

type PatternSlot

type PatternSlot struct {
	// The item is one of the following:
	Nil      bool
	Wildcard bool

	ID  *string
	Var *PatternVar
	Num *string // we don't need to treat this as a number anywhere, so keep as a string

	Negated bool // this item is negated
}

func (PatternSlot) String

func (p PatternSlot) String() (str string)

type PatternVar added in v0.8.0

type PatternVar struct {
	Name        *string
	Constraints []*Constraint // any constraints on this var
}

type PrintStatement

type PrintStatement struct {
	Values *[]*Value
}

PrintStatement outputs the string, id, or number to stdout.

type Production

type Production struct {
	Name        string
	Description *string // optional description to output as a comment in the generated code

	VarIndexMap map[string]VarIndex // track the buffer and slot name each variable refers to

	Matches      []*Match
	DoStatements []*Statement

	AMODLineNumber int // line number in the amod file of the this production
}

Production stores information on how to match buffers and perform some operations. It uses a small language to modify states upon successful matches.

func (Production) LookupMatchByBuffer

func (p Production) LookupMatchByBuffer(bufferName string) *Match

func (Production) LookupMatchByVariable

func (p Production) LookupMatchByVariable(varName string) *Match

LookupMatchByVariable checks all matches for a variable by name. This is pretty inefficient, but given the small number of matches in a production, it's probably not worth doing anything more complicated. We could store all the vars used in all the matches on the Match itself and look it up there.

func (Production) LookupSetStatementByBuffer

func (p Production) LookupSetStatementByBuffer(bufferName string) *SetStatement

LookupSetStatementByBuffer is used when combining several set consecutive statements on one buffer. So this:

set goal.foo to 1
set goal.bar to 10

is treated like this:

set foo, bar on goal to 1, 10

type RecallStatement

type RecallStatement struct {
	Pattern    *Pattern
	MemoryName string
}

RecallStatement is used to pull information from memory.

type SetSlot

type SetSlot struct {
	Name      string
	SlotIndex int // (this slot index in the chunk)
	Value     *Value
}

type SetStatement

type SetStatement struct {
	Slots *[]SetSlot // (1) set this slot (optional)
	Chunk *Chunk     // (1) if we are setting slots, point at the chunk they reference for easy lookup

	Buffer buffer.BufferInterface // (1 & 2) buffer we are manipulating

	Pattern *Pattern // (2) pattern if we are setting the whole buffer
}

SetStatement will set a slot or the entire contents of the named buffer to a string or a pattern. There are two forms:

(1) set (SetSlot) of (Buffer) to (SetValue)
(2) set (Buffer) to (Pattern)

func (*SetStatement) AddSlot

func (s *SetStatement) AddSlot(slot *SetSlot)

type Statement

type Statement struct {
	Clear  *ClearStatement
	Print  *PrintStatement
	Recall *RecallStatement
	Set    *SetStatement
	Stop   *StopStatement
}

type StopStatement added in v0.8.0

type StopStatement struct {
}

StopStatement outputs a stop command. There are no parameters.

type Value

type Value struct {
	Nil    *bool // set this to nil
	Var    *string
	ID     *string
	Str    *string
	Number *string
}

Value holds something that may be printed.

func (Value) String added in v0.8.0

func (v Value) String() string

type VarIndex added in v0.2.0

type VarIndex struct {
	Var      *PatternVar
	Buffer   buffer.BufferInterface
	SlotName string
}

VarIndex is used to track which buffer slot a variable refers to

Directories

Path Synopsis
Package modules implements several ACT-R modules.
Package modules implements several ACT-R modules.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL