API¶
Agent¶
-
Agent
(id, beliefs, desires, plans, determinePreferences, selfUpdatesPossible=true)¶ JS-son agent generation function
Arguments: - id (string) – unique identifier for the agent
- beliefs (object) – initial beliefs of the agent
- desires (object) – the agent’s desires
- plans (array) – the agent’s plans
- determinePreferences (function) – preference function generator; by default (if no function is provided), the preference function turns all desires into intentions
- selfUpdatesPossible (boolean) – If true, agents can update their own belief, plans et cetera via a body of their plans. Defaults to
true
.
Returns: object – JS-son agent object
-
RemoteAgent
(id, beliefs, next)¶ JS-son remote agent generation function. The remote agent is an environment’s interface to a JS-son agent that runs in a different context, for example on a client that accesses a server-side environment
Arguments: - id (string) – unique identifier for the (remote) agent
- beliefs (object) – initial beliefs of the agent
- next (function) – function that implements and interface to the remote implementation
Returns: object – JS-son remote agent object
-
Belief
(id, value)¶ JS-son agent belief generator
Arguments: - id (string) – the belief’s unique identifier
- value (any) –
Returns: object – JS-son agent belief
-
Desire
(id, body)¶ JS-son agent desire generator
Arguments: - id (string) – the desire’s unique identifier
- body (function) – a function for computing the desires value based on current beliefs
Returns: object – JS-son agent desire
-
Intentions
(beliefs, desires, preferenceFunctionGenerator)¶ JS-son agent intentions generator
Arguments: - beliefs (object) – the agent’s current beliefs
- desires (object) – the agent’s desires (from which the intentions are filtered)
- preferenceFunctionGenerator (function) –
Returns: array – JS-son agent intentions
-
Plan
(head, body)¶ JS-son plan generator
Arguments: - head (function) – Determines if plan is active
- body (function) – Determines what actions to execute
Returns: object – JS-plan
Environment¶
-
Environment
(agents, state, update, render, stateFilter, runner)¶ JS-son environment generator
Arguments: - agents (array) – JS-son agents to run
- state (object) – Initial environment state
- update (function) – Update function, in particular for processing agent actions
- render (function) – Visualization function of the environment’s current state
- stateFilter (function) – Function for filtering state that agents should receive
- runner (function) – Function that manages the next “tick”
Returns: object – JS-son environment object
Grid World¶
-
GridWorld
(agents, state, fieldTypes, stateFilter)¶ JS-son grid world environment
Arguments: - agents (array) – JS-son agents to run
- state (object) – Initial environment state
- fieldTypes (object) – Object: all field types (id: {…properties}) the environment supports
- stateFilter (function) – Function for filtering state that agents should receive
Returns: object – JS-son environment object with grid world render function
-
FieldType
(id, generateClass, generateCharRep, generateConsequence, generateAnnotation)¶ JS-son world field type generator
Arguments: - id (string) – Unique identifier of field type
- generateClass (function) – Determines field’s table cell class based on state, position
- generateCharRep (function) – Determines field’s cli representation, based on state, position
- generateConsequence (function) – Determines effect of action in field to agent and env
- generateAnnotation (function) – Determines field’s annotation, based on state, position
Returns: object – JS-son grid world field type