An agent-based system consists of an environment populated by entities, relationships, messages, concepts, events, descriptions, and roles. An agent is an entity that plays one or more roles in the environment.
An agent perpetually:
1. Inspects the environment.
2. If the environment has reached the goal state, then quits.
3. Selects an action to perform.
4. Modifies the environment by performing the action.
A reactive agent selects the environment based purely on its perception of the state of the environment. A simple stimulus-response table can be used. A reflective agent may use an internal model of the environment to help select the action to be performed. The internal model can be thought of as a knowledge base. Performing an action may update the agent's knowledge base as well as the agent's environment.
/**
* The environment contains entities,
agents, events, etc.
* An agent's mode of the environment
may be partial or inaccurate.
*/
interface Environment { }
/**
* Knowledge base or ontology containing
agent's
* model of the enviroinment. Only
deliberative
* agents need complicated models. For a
reactive
* agent the model only needs to be a
table of
* stimulus-response rules.
*/
interface KBase { }
interface Action {
/**
* Updates the environment.
*/
void perform(Environment env, KBase
kbase);
}
abstract public class Agent extends Thread {
protected Environment env;
protected KBase kbase;
/**
* Has the environment reached the goal state?
*/
abstract protected boolean goal(Environment
env, KBase kbase);
/**
* this method reflects the agent's intentions.
*/
abstract protected Action
select(Environment env, KBase kbase);
/**
* An agent perpetually updates its environment until its
* goals have been reached.
*/
public void run() {
while(!goal(env, kbase)) {
Action action = select(env,
kbase);
action.perform(env, kbase);
}
}
}