API¶
Agent¶
- Agent(config, id, beliefs, desires, plans, determinePreferences, selfUpdatesPossible, reviseBeliefs, reviseGoals)¶
JS-son agent generation function. Note that an agent can be instantiated using either a configuration object or a series of parameters
- Arguments:
config (object) – agent configuration object
config.id (string) – unique identifier for the agent
config.beliefs (object) – initial beliefs of the agent
config.desires (object) – the agent’s desires; default: empty array (no desire deliberation)
config.plans (array) – the agent’s plans
config.determinePreferences (function) – preference function generator; by default (if no function is provided), the preference function turns all desires into intentions
config.selfUpdatesPossible (boolean) – If true, agents can update their own belief, plans et cetera via a body of their plans. Defaults to
true
.config.reviseBeliefs (function) – belief revision function that takes the agent’s currently held beliefs as well as the “new” beliefs obtained from the environment and revises the agent’s beliefs based on this. Defaults to:
(oldBeliefs, newBeliefs) =>
({ ...oldBeliefs, ...newBeliefs })
config.reviseGoals (function) – goal revision function that takes the agent’s beliefs and goals and then updates the goals. Defaults to:
(beliefs, goals) => goals
ORid (string) – unique identifier for the agent
beliefs (object) – initial beliefs of the agent
desires (array) – 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
.reviseBeliefs (function) – belief revision function that takes the agent’s currently held beliefs as well as the “new” beliefs obtained from the environment and revises the agent’s beliefs based on this. Defaults to:
(oldBeliefs, newBeliefs) =>
({ ...oldBeliefs, ...newBeliefs })
reviseGoals (function) – goal revision function that takes the agent’s beliefs and goals and then updates the goals. Defaults to:
(beliefs, goals) => goals
- 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; can be a function or a JS-son goal
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