Archive

Archive for the ‘AgentThread’ Category

AgentThread innards

September 10th, 2008 heckel No comments

I’ve started filling out the major components of the agent core; I have a base class for AgentBehaviors, am filling in functionality for the AgentThread, and have rough versions of the AgentController, GameController and main application threads. Most of the work I’ve done so far is on the AgentThread.

The AgentThread class has six major methods at present:

  • run() : The meat of the agentthread. It first sorts the behaviors by priority and builds the generator functions for each behavior. It then goes into its main loop; each iteration includes a subloop which iterates over each behavior as many times as it is able given available resources. At present, it depends on the AgentController to tell it when to stop, collect its answers, and  reset for the next run. At present, it is not guaranteed to run all behaviors in the list.
  • addBehavior(behavior,priority): Adds a behavior at a given priority — default is priority 0. Lower priorities run first.
  • stop(): Tells the thread to stop running completely
  • reset(): Tells the thread to collect its effector answers and reset for the next run. Also increments the step counter.
  • setPercepts(): Sets up percepts for next timestep. Should be called before reset()
  • getEffectors(): Gets the collected effector requests. Should be called after reset(). Returns false if effectors are not yet ready for harvest

These will change as the agentthread becomes more properly resource aware and is given a specific quantity of system time to work with. Also note that at present, the run thread starts working immediately after returning effector results; ultimately it will wait until the AgentController thread tells it to continue.

Categories: Agent Core, AgentThread Tags: