aima.core.agent.impl.AbstractAgent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
The newest version!
package aima.core.agent.impl;
import aima.core.agent.Action;
import aima.core.agent.Agent;
import aima.core.agent.AgentProgram;
import aima.core.agent.Percept;
/**
* @author Ravi Mohan
* @author Ciaran O'Reilly
* @author Mike Stampone
*/
public abstract class AbstractAgent implements Agent {
protected AgentProgram program;
private boolean alive = true;
public AbstractAgent() {
}
/**
* Constructs an Agent with the specified AgentProgram.
*
* @param aProgram
* the Agent's program, which maps any given percept sequences to
* an action.
*/
public AbstractAgent(AgentProgram aProgram) {
program = aProgram;
}
//
// START-Agent
public Action execute(Percept p) {
if (null != program) {
return program.execute(p);
}
return NoOpAction.NO_OP;
}
public boolean isAlive() {
return alive;
}
public void setAlive(boolean alive) {
this.alive = alive;
}
// END-Agent
//
}